Siddhpura Amit
Siddhpura Amit

Reputation: 15128

Zoom in/out in webview android

Hi i have used following code for built in zoom in zoom out control

   mWebView = (WebView) findViewById(R.id.webView1);
    mWebView.getSettings().setBuiltInZoomControls(true);
    mWebView.getSettings().setSupportZoom(true);

also i have used code like below

    mWebView.setWebViewClient(new MyWebViewClient());
        mWebView.loadUrl(sabNZBurl);
        mWebView.getSettings().setDomStorageEnabled(true);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setBuiltInZoomControls(true);
        mWebView.getSettings().setSupportZoom(true);
        backwardBtn = (Button) findViewById(R.id.btnBackWard);
        cancelBtn = (Button) findViewById(R.id.btnCancel);
        refreshBtn = (Button) findViewById(R.id.btnRefresh);
        forwardBtn = (Button) findViewById(R.id.btnForward);

        backwardBtn.setOnClickListener(this);
        cancelBtn.setOnClickListener(this);
        refreshBtn.setOnClickListener(this);
        forwardBtn.setOnClickListener(this);

   final class MyWebViewClient extends WebViewClient {
    @Override
    // Show in WebView instead of Browser
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }

    @Override
    public void onLoadResource(WebView view, String url) {
        super.onLoadResource(view, url);

    }

    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);
        PD.dismiss();
        view.getSettings().setBuiltInZoomControls(true);
        view.getSettings().setSupportZoom(true);
    }

}

but still webview does not come with built in zoom in zoom out control can any body help me to solve this problem

Upvotes: 3

Views: 10711

Answers (4)

Balaji
Balaji

Reputation: 31

Try this, I got answer

WebSettings webSetting = mWebView.getSettings();
            webSetting.setBuiltInZoomControls(true);

Upvotes: 3

pranavjayadev
pranavjayadev

Reputation: 929

May be this is what your are searching..

settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
settings.setUseWideViewPort(true);
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);

Upvotes: 2

Amit Jayaswal
Amit Jayaswal

Reputation: 1723

try this:-

webview.getSettings().setUseWideViewPort(true);

Upvotes: 1

throrin19
throrin19

Reputation: 18207

Do you have a viewport meta tag in web page to display? If yes and if it contains user-scalable="no" then it is normal, the HTML itself disables zoom. Simply edit the tag like this:

<meta name="viewport" content="initial-scale=1.0, user-scalable=yes, width=device-width" />

Upvotes: 3

Related Questions