Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WebView seems to ignore "viewport" information on web pages

I have a website that is using the viewport META tag to tell mobile browsers how to display content ( ). Viewing the page in the Android browser looks correct (and iPhone, etc).

When I load the page into a WebView component in an android Application, the WebView ignores the "VIEWPORT" tag, and renders the page at "full" resolution, which is zoomed-in in this case.

like image 246
Evan Avatar asked May 25 '10 22:05

Evan


3 Answers

Link in the accepted answer and this will help to understand viewport on Android.

In my scenario, fixed width is used, the solution is:

settings.setUseWideViewPort(true)
settings.setLoadWithOverviewMode(true)
like image 161
Lym Zoy Avatar answered Sep 18 '22 15:09

Lym Zoy


As the docs say in the link in the best answer, you can specify using a meta tag how the device should react to the size of your web app compared to the screen. The following tag made an Android phone respect the viewport size of my web app:

<meta name="viewport" content="target-densitydpi=high-dpi" />
like image 39
jorisw Avatar answered Sep 17 '22 15:09

jorisw


Try using this method of WebSetting class

setUseWideViewPort (boolean use)

I use this to tell Android webview to consider my "viewport" tag

like image 24
onmyway133 Avatar answered Sep 21 '22 15:09

onmyway133