Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to disable the zoom feature on input fields in webview?

When a user clicks in an input field or textarea, the application zooms in. Is there a simple way to disable it?

Currently have the meta tag:

meta name="viewport" content="width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi;"

Everything looks great till I look at it on a device with Android 2.2 Specifically HTC Evo 4G.

like image 660
dlewis22 Avatar asked Sep 13 '10 17:09

dlewis22


2 Answers

I messed around with this alot.

You have to have different solutions for different screen sizes and phones, done serverside.

This works for a HTC desire for instance:

<meta content='True' name='HandheldFriendly' />
<meta content='width=640px; initial-scale=0.50; maximum-scale=0.50;minimum-scale=0.50;' name='viewport' />
<meta name="viewport" content="width=640px" />

This is for an iphone:

<meta name="viewport" content="width=640px,user-scalable=0" />
like image 127
TheisEgeberg Avatar answered Sep 28 '22 00:09

TheisEgeberg


webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM); 

This method was deprecated in API level 19.

this works in the last android versions 4.4.2.

webView.setInitialScale(0);//default,no zoom
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setLoadWithOverviewMode(false);
webView.getSettings().setUseWideViewPort(false);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
like image 27
jeff wang Avatar answered Sep 28 '22 00:09

jeff wang