Disable pinch/zoom in Android 2.1 browser on HTC devices
I'm building a mobile site a开发者_开发百科nd have the following meta tag set in the header:
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
Unfortunately, this isn't working on HTC devices (HTC Hero, etc) with Android 2.1. Any ideas on how I can disable pinch-to-zoom in this browser? Works fine on the iPhone.
I have contacted HTC about this issue and they have informed me that they don't have support for the viewport meta tag at all and there is no other way to disable zoom.
Quite disappointing.
This works on the default android and iPhone browsers. Although sadly it doesn't work for HTC's custom browser (as asked).
<meta content='True' name='HandheldFriendly' />
<meta content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' name='viewport' />
<meta name="viewport" content="width=device-width" />
Just an idea, maybe not useful (not tested) :
Did you look into javascript support in Android's WebView? I think you might be able to call WebSettings.setBuiltInZoomControls(false);
which might do what you need.
I've also played with this a LOT, and found no combination that actually disables the zoom. You can however set the initial scale of the page, so when the user access it, it is in the correct zoom level. The default zoom level for android browsers is "medium", but as mentioned, if the user changes this in settings (or pinch zooms), it will not be prevented.
精彩评论