36

I'm building a mobile site and 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.

8three
  • 369
  • 1
  • 3
  • 3

4 Answers4

33

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.

Garrows
  • 3,031
  • 3
  • 25
  • 21
  • 6
    +1 Very disappointing. Thanks for sharing this information with us. – René Sep 23 '11 at 10:29
  • weird, because `width=device-width` helped me out of another jam with my HTC EVO, but still can't get no-zoom to work. So maybe only some `viewport` attributes work... – Jeff Dec 22 '12 at 01:00
9

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" />
Garrows
  • 3,031
  • 3
  • 25
  • 21
0

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.

Sephy
  • 50,022
  • 30
  • 123
  • 131
  • 1
    I'm not developing an android app though - I'm developing a mobile website meant to be viewed in a browser. Thanks though. – 8three Aug 11 '10 at 16:59
  • yeah but still, you know how to write javascript? The javascript will be loaded by android's webviews and browser, so it should be executed. I gave you the method to call from the javascript which might be able to prevent zooming. – Sephy Aug 11 '10 at 17:15
  • Yeah, I understand. Thanks again for the suggestion, but unfortunately, it doesn't work. Still looking for a solution to this. It seems to only happen on HTC devices. – 8three Aug 19 '10 at 19:30
  • I need this figured out as well. – balexander Aug 19 '10 at 19:52
0

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.

BoomShaka
  • 1,571
  • 7
  • 27
  • 40