I'm using an android's webview to display some html with javascript being executed when the DOM is ready; but screen.width gives the wrong value, unless I'm using some timeout before querying for it(on emulators and real devices)
The problem is with devices of high/low density. For example, a device of size 480 X 800 of high density will results in screen of 320 x 533 (it divides by 1.5 both screen width and height) and for screen of size 240x320 of low density it gives 320x426 (again, it divides by 0.75 both width and height).
When I apply some css and set the body's width to 100%, it flickers, since the body's width is being set to 320px and after half a second it is being set again, this time to the real size of 480px.
Using a timer to query the screen's width and height prior to applying some css is unacceptable, since on different devices, different time intervals are needed (300ms, 500ms) - How can I apply css with different screen sizes
emulators:
FWQVGA (240×432, low density, normal screen)
HVGA (320×480, medium density, normal screen)
WVGA800 (480×800, high density, normal screen)
Is there any solution to this problem?