Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pinch Zoom in webview [Android]

On my website, which is loaded in the webview, there is a map. There are also java scripts that detects double tap for zoom, dragging etc. But is it possible to have a javascript that detects the use of pinch zoom ? there are several examples of it working on an iphone, and on my website there is a script for the pinch zoom but it is only working on iphone.....

Is it possible to get it to work on Android ?

Thanks

like image 450
Roskvist Avatar asked Sep 29 '10 09:09

Roskvist


People also ask

How do I zoom out in Webview Android?

webview. getSettings(). setLoadWithOverviewMode(true); This will cause the webview to be zoomed out initially.


2 Answers

When you would like to scale web content in you WebView and enable pinch and zoom, I prefer the simple android way.

webView.getSettings().setBuiltInZoomControls(true);

and you can even hide the controls if you are using API 11 or higher

webView.getSettings().setDisplayZoomControls(false)
like image 112
Jesse Black Avatar answered Sep 21 '22 01:09

Jesse Black


There's an open-source library called android-pinch that you can include in your project to enable pinch zoom if you switch your WebView to a WebImageView. Here's an example of usage...

// create the WebImageView object from xml
WebImageView img = (WebImageView) findViewById(R.id.main_pic);
// fetches the image in a background thread
img.setImageFromURL("http://www.mysite.com/mypicture.jpg");
// enable pinch-zoom abilities on the image
new PinchImageView(img);
like image 34
Ryan Berger Avatar answered Sep 20 '22 01:09

Ryan Berger