Reputation: 1443
I've been banging my head against the wall for the whole day now, and i need some help :(
The problem is, that i have a WebApp that was designed for 640x960
.
We didn't have time to write css for each screen size, so i've used initial-scale, maximum-scale, minimum-scale
in the viewport
meta tag to scale the app to different screen sizes.
The problem is, that in Android 4.4
, no matter what i do, it always scales the app up, but never down!
I mean if i use a value of 0.7
, the app is scaled up. If i use a value of 1.3
, it is scaled up again :/
I've tried to change the targetSdkVersion
to different versions to get the old behavior, but with no luck.
Can someone help me?
UPDATE:
So i ended up using style="zoom: <value>%"
on the body
tag. I calculate the percentage based on the difference between the current device screen size and the resolution my app was designed for. Now everything fits.
Upvotes: 3
Views: 11000
Reputation: 9821
Just had a run through of this after not quite being sure of the answer myself.
http://www.gauntface.co.uk/blog/2013/11/29/desktop-site-and-the-viewport/
You want a viewport without an initial-scale if you only want the webpage to fit the WebView's width.
Things that will affect the WebView:
If you want to prevent the user from zooming in or out, use user-scalable=no in the viewport rather than set a min and max.
Upvotes: 2
Reputation: 3231
A viewport of
<meta name="viewport" content="width=640, initial-scale=1">
should make your fixed layout always fit (see MDN for more on the viewport meta tag).
You could be bumping in some of the following:
WebSettings
:
setUseWideViewport
(which overrides the viewport meta tag) orsetInitialScale
(which can alter the size of the viewport).The best way to check if it's the content's fault or the WebView's fault is to see if the page works in Chrome on Android:
targetSdkVersion
to 19 and try disabling WebSettings, changing your layout to fixed size, etc.. to see what's causing the problem. Maybe start from the other end - by making a super trivial WebView app that just loads the page - confirm that works and then slowly introduce changes to see which one causes the problem,If you're still stuck post a zip that contains sources with a repro (doesn't have to be the full app, just the minimum to demonstrate the problem) and I can try and help you more from there.
Upvotes: 8