I'm trying to get my mind around how to specify CSS dimensions in an embedded WebView in my app for Android 4.0 and higher. On the three devices I'm testing with (Nexus 4/7/10), it appears that if I use the following viewport directive:
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
...then any CSS dimensions in content loaded into that webview are exactly the same as device-independent pixels. That is to say, on my Nexus 10, which is 2560 physical pixels wide, if in my webview I specify something to have a width of 1280, it will exactly fill the width of the screen.
I love the idea that I could use device-independent pixels in my CSS, but I need to ensure that I am able to calculate the precise available space in such DIPs. So I expect that if a WebView has, say, 1920 physical pixels in width, its width in CSS pixels should be:
- On an mdpi display, 1920px.
- On an hdpi display, 1280px.
- On an xhdpi display, 960px.
- On an xxhdpi display, 640px.
Is this true?