Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable zoom controls and pinch zoom in a WebView?

The default Browser app for Android shows zoom controls when you're scrolling and also allows for pinch zooming. How can I enable this feature for my own Webview?

I've tried:

webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); 

but neither of the features get enabled as a result. Btw I've set a WebChromeClient and a WebViewClient for the Webview if that makes a difference.

Thanks!

like image 713
Robert Bana Avatar asked Aug 19 '11 11:08

Robert Bana


People also ask

How do I enable zoom in WebView?

This example demonstrate about How to enable webview zoom controls in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do I zoom out in WebView Android?

getSettings(). setBuiltInZoomControls(true); per this answer to default my view to zoomed out and to be able to pinch-to-zoom.

How do I pinch zoom with my mouse on Android?

Press and hold Ctrl and press and hold left mouse and while doing that move your mouse.


1 Answers

Strange. Inside OnCreate method, I'm using

webView.getSettings().setBuiltInZoomControls(true); 

And it's working fine here. Anything particular in your webview ?

like image 195
zov Avatar answered Sep 22 '22 07:09

zov