我删除了this.appView.setInitialScale(0);在DroidGap.java和init WebView中如下
WebSettings ws = wv.getSettings();
ws.setJavaScriptEnabled(true);
ws.setDomStorageEnabled(true);
ws.setLightTouchEnabled(false);
ws.setDatabaseEnabled(true);
String databasePath = getApplicationContext().getDir("database",
Context.MODE_PRIVATE).getPath();
ws.setDatabasePath(databasePath);
ws.setSupportZoom(false);
ws.setBuiltInZoomControls(false);
wv.requestFocusFromTouch();
DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
int orient = getRequestedOrientation();
float width = 480.0f;
float height = 320.0f;
if(orient == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
width = 320.0f;
height = 480.0f;
}
width*=2;height*=2;
final float scale = Math.min(metric.widthPixels / width, metric.heightPixels / height);
int web_scale = 100;
if(android.os.Build.PRODUCT.equals("blaze")) {
web_scale = (int) (scale * 96);
}else {
web_scale = (int) (scale * 100);
}
wv.setInitialScale(web_scale);
在我的网页中,视口是:
<meta name="viewport" content="width = device-width,initial-scale=0.75,minimum-scale=0.1,maximum-scale=3.0,user-scalable=yes" />
它适用于4.0设备,但在2.3或更低版本下运行时,页面似乎比预期的要大。 提前通知任何建议。
我发现它在我的手机上不起作用(HTC G11 Incredible S),但适用于其他人(星系音符,星系II,星系连接,摩托里程碑2)