kanna
kanna

Reputation: 463

HTML page should fix all the android device

I have tried the following code to fit the webpage based on the device screen size.

    WebView mWebView=(WebView)findViewById(R.id.webView1);
    mWebView.loadUrl("file:///android_asset/test/index.html");
    mWebView.setInitialScale(1);
    mWebView.getSettings().setLoadWithOverviewMode(false);
    mWebView.getSettings().setUseWideViewPort(true);
    mWebView.getSettings().setBuiltInZoomControls(true);
    mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    mWebView.setScrollbarFadingEnabled(false);

In this Zoomcontrols is working fine. But webpage is not fixed to the device screen size.
Can anyone give me suggestions...?

Upvotes: 0

Views: 181

Answers (1)

David Ng
David Ng

Reputation: 470

Try adding the following meta tag to your HTML file

<meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" />

Upvotes: 2

Related Questions