Making Sense of Android meta-viewport scaling: What am I missing? Making Sense of Android meta-viewport scaling: What am I missing? android android

Making Sense of Android meta-viewport scaling: What am I missing?


Interesting can of worms you've opened up there. As you try out more devices you'll probably see even more weirdness, and random bugs. Interesting times! :-)

I suspect that somewhere down the line you might want to give up, and just try to...

  • Stick with as simple settings as possible.
  • Accept the pixel width the device chooses to report.
  • Rely on adaptive/fluid layout and relative widths to make things work across different screen widths.
  • Use native CSS properties for a resolution neutral rendering of rounded corners, shadows and gradients.
  • Use vector formats (svg, icon-fonts, etc.) as much as possible
  • and (important) Use high-res border-images as well as background-images coupled with the well-supported background-size property1 to make things render nice and crisp2.

1) To provide backwards compatibility to older browsers (like MSIE8) you'll need to use double background-image declarations - like:

background-image: url(low-res.png);        /* CSS2 */background-image: url(high-res.png), none; /* CSS3 */background-size:  100px 10px;             /* CSS3 */

2) The -webkit-max-device-pixel-ratio media query may also help, but as the name implies it only works for webkit browsers.


Ramble:

The new generation Android and iOS devices have such varying screen DPIs that they've resorted to reporting CSS pixels rather than actual device pixels. This is both good or bad - depending on how you look at it.

It's bad because you're not guaranteed anymore the down-to-the-device-pixel control you were used to having, working with the mostly homogenous screens of yore.

On the other hand, it's good because you know your designs will never render so tiny that they can't be read/used by regular humans.

The problem with using target-densitydpi=device-dpi is that it while it works wonders on a 7inch wide 800px screen, it will completely ruin your application on a 4inch wide 960px screen.


$(document).ready(function() { $('meta[name=viewport]').attr('content','width=1024, user-scalable=no'); });

Seem to work for disabling the user scaling after the correct scaling have been applied