开发者

Android setInitialScale is not working for mobile pages

I am creating an application where I have to resize the content of a webview. Everything works fine until I load inside the webView a mobile page. No matter what value I set to setInitialScale(n) the content of webView is not resizing. Below is the code I am using:

webView.getSettings().setSupportZoom(true);  
webView.开发者_StackOverflow中文版getSettings().setUseWideViewPort(true);
webView.setInitialScale(33);
webView.loadUrl("http://m.jurnalul.ro");

Is there any possibility to zoom out or in the content of a WebView that contains a mobile page.

Thank you very much


Have you tried :

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

switch (metrics.densityDpi) {
case DisplayMetrics.DENSITY_HIGH:
    webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
    break;

case DisplayMetrics.DENSITY_MEDIUM:
    webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
    break;

case DisplayMetrics.DENSITY_LOW:
    webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.CLOSE);
    break;

default:
    webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
    break;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜