Android webview pinch zoom local image
Asked Answered
P

1

5

Hey I'm trying to get pinch to zoom working on a Webview of my app but cant, it just displays the image really zoomed in (probably displaying it 100%)

here is how i got the webview to work.

In the activity I added

 WebView mWebView = (WebView) findViewById(R.id.webview);
 mWebView.getSettings().setJavaScriptEnabled(true);
 mWebView.loadUrl("file:///android_asset/sitemap.png");

The image is in the assets folder and is named sitemap.png

The layout xml I used for the webview is

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

I have not added anything else to the code. Can you tell me what isnt working, as say it displays the picture perfectly but i cant pinch zoom, what is the easiest way to solve this as i am nooby

Cheers

Pairoar answered 20/8, 2011 at 17:40 Comment(0)
D
11

In API 3, you can use setBuiltInZoomControls:

webView.getSettings().setBuiltInZoomControls(true);

See Also: Disable pinch zoom in WebView?

Davita answered 20/8, 2011 at 18:22 Comment(3)
can you elaborate more for me please spent last 2 hours trying to get it working and still cantPairoar
mWebView.setBuiltInZoomControls(true);Davita
mWebView.getSettings().setBuiltInZoomControls(true); In case some people don't know about getSettings()Sobriety

© 2022 - 2024 — McMap. All rights reserved.