Sie sind auf Seite 1von 4

sign up

Stack Overflow

log in

Questions Tags Users Badges Unanswered Ask

Read this post in our app!

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

57

android

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!
share

improve this question


Robert Bana
557 2 6 17

Asked
Aug 19 '11 at 11:44

Vivek Kalkur
1,638 2 12 34

Edited
Dec 13 '11 at 13:08

3 Answers

153

Order By

Strange. Inside OnCreate method, I'm using


webView.getSettings().setBuiltInZoomControls(true);

Votes

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


share

improve this answer


zov
2,070 1 8 16

16

Answered
Aug 24 '11 at 7:53

While this will allow pinch-to-zoom, it will also display a zoom overlay control (Galaxy S3). In order to disable the on-screen zoom tool, but retain the pinch-to-zoom functionality, you
need to call webView.setDisplayZoomControls(false) as well. Lev Nov 6 '14 at 9:38
^ webView.getSettings().setDisplayZoomControls(false); wiseindy Apr 18 '15 at 18:26
add a comment

11

Check if you don't have a ScrollView wrapping your Webview.


In my case that was the problem. It seems ScrollView gets in the way of the pinch gesture.
To fix it, just take your Webview outside the ScrollView.

share

improve this answer


Tiago
2,878 2 34 48

Answered
Sep 2 '13 at 4:56

you saved my day allemattio Dec 13 '13 at 16:44


add a comment

Use these:
wv.getSettings().setBuiltInZoomControls(true);
wv.getSettings().setDisplayZoomControls(false);

share

improve this answer

Dario Bruzzese
261 4 7

Answered
Sep 15 '15 at 13:12

plus 1, for the answer.. helped me. Akshatha Srinivas Jun 13 at 12:42
add a comment

Your Answer

log in
or

Name

Email

By posting your answer, you agree to the privacy policy and terms of service.

Post Your Answer

meta chat tour help blog privacy policy legal contact us full site
Download the Stack Exchange Android app
2016 Stack Exchange, Inc