views:

164

answers:

1

I am trying to get the WebView to have similar behavior as the android browser. The browser opens all pages in a way that tries to fit their width to the screen. However, the default behavior of the WebView is to start at a 100% pixel scale so it starts zoomed in on the top left corner.

I have spent the last couple hours trying to find a way to get the WebView to scale the page to the screen like it does in the browser but I'm not having any luck. Has anyone found a way to accomplish this?

I see is a setting called setLoadWithOverviewMode, but that didn't appear to do anything at all. I also experimented with setInitialScale but on different screen sizes and web page sizes that won't be as graceful as the browsers scaling.

Any one have any leads?

Thanks

A: 

Try using a wide viewport:

 webview.getSettings().setUseWideViewPort(true);
Brian
Thank you, that seems to be in the right direction. That in and of itself didn't seem to do anything, but with the combination of setInitialScale(50) it worked perfectly in portrait. However, holding the phone in landscape, it doesn't fit to screen. Are there other settings I should be using in addition to that one? Here is what I have currently: setBuiltInZoomControls(true), setUseWideViewPort(true), setInitialScale(50). I would like it to fit well to the screen no matter the size or density of the screen. Thanks again.
littleFluffyKitty