Android的setInitialScale不工作的移动网页 [英] Android setInitialScale is not working for mobile pages

查看:558
本文介绍了Android的setInitialScale不工作的移动网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个应用程序,我必须调整网页视图的内容。直到我加载web视图内的移动网页一切正常。无论我设置为 setInitialScale什么值(N) web视图的内容不调整大小。下面是code我使用的:

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.getSettings().setUseWideViewPort(true);
webView.setInitialScale(33);
webView.loadUrl("http://m.jurnalul.ro");

是否有可能缩小或包含移动页面的WebView的内容。

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

非常感谢你。

推荐答案

你试过:

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;
}

这篇关于Android的setInitialScale不工作的移动网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆