Reputation: 111
I am working on an android app with a webview element and local html pages and images.
When a link goes to and image (example: images/image.png) I want to let the user zoom in and out.
But I don't want the zoom to work on the html pages.
This is why webView.getSettings().setBuiltInZoomControls(true);
doesn't work for me.
Any suggestions?
Upvotes: 2
Views: 2360
Reputation: 3231
You could specify user-scalable=no
on your viewport to disable user scaling. See here for more on the viewport tag.
Upvotes: 1
Reputation: 111
The answer was simple actually.
webView.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
String fileEx = url.substring(Math.max(0, url.length() - 3));
if(fileEx.equals("jpg")){
webView.getSettings().setBuiltInZoomControls(true);
}else{
webView.getSettings().setBuiltInZoomControls(false);
}
view.loadUrl(url);
return true;
}
});
Upvotes: 2
Reputation: 9
Simplest solution would be to call webView.getSettings().setBuiltInZoomControls(true);
when the link goes to the image and webView.getSettings().setBuiltInZoomControls(false);
when the users back to main html
Upvotes: 0