0

This question is more or less an exact duplite of:

Forcing a webpage to fit into a webview

But that is because the provided answer does not work.

So: I have a WebView that loads some HTML content. I need to shrink/zoom the content so that it fits the width of the WebView. The height of the WebView should adjust accordingly. The WebView is part of a larger layout that, in turn, is inside a ScrollView.

Even though I tried the following:

WebView webView = (WebView)findViewById(R.id.webView);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);

The web content is consistently too large for the WebView and I have a horizontal scroll bar in the WebView. The other part of the problem seems to work, i.e. the height of the WebView fits the content without a scroll bar and the size of the layout in the ScrollView is correct as well.

So, are there any other factors to consider? Is there anything that the HTML itself must "get right" for this to work?

Community
  • 1
  • 1
david.mihola
  • 12,062
  • 8
  • 49
  • 73
  • http://stackoverflow.com/questions/9055347/fitting-webpage-contents-inside-a-webview-android Might be of help – prettyvoid Oct 23 '14 at 09:37
  • Thank you! I hadn't seen that thread before - and indeed, my HTML contains the `viewport` meta tag mentioned in http://stackoverflow.com/a/19446615/763935. I'll see if I can have that removed and see if it works then... – david.mihola Oct 23 '14 at 10:04
  • Could [this][1] be helpful? BR Martin E. [1]: http://stackoverflow.com/questions/3916330/android-webview-webpage-should-fit-the-device-screen – NicTesla Nov 03 '14 at 16:56

0 Answers0