如何更改webview内容大小?

时间:2013-10-24 17:27:01

标签: android webview

我的程序的主要类包含以下代码

public class HTMLViewActivity extends Activity {
    private WebView web;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        DisplayMetrics metrics = this.getResources().getDisplayMetrics();
        int width = metrics.widthPixels;
        int height = metrics.heightPixels;
        web = (WebView) findViewById(R.id.webView1);
        web.setLayoutParams(new LinearLayout.LayoutParams( width , height));
        web.getSettings().setJavaScriptEnabled(true);
        web.getSettings().setRenderPriority(RenderPriority.HIGH);
        web.getSettings().setDomStorageEnabled(true);
        web.getSettings().setDatabaseEnabled(true);
        web.getSettings().setDatabasePath("/data/data/" + "web" + "/databases/");
        web.getSettings().setAppCacheEnabled(true);
        web.setSoundEffectsEnabled(true);
        web.setKeepScreenOn(true);
        web.clearView();
        web.measure(10, 10);
        web.loadUrl("http://www.fullscreenmario.com/stable/mario.html");
    }
}

当我在此webview中加载页面时,它非常大,我无法更改此内容。在移动Chrome中,它具有正常大小

enter image description here enter image description here

0 个答案:

没有答案