Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebView wrap-content

Is it possible to load a URL in a WebView and resize it to fit the screen? I mean I want to make the WebPage small so that the user doesn't need to scroll. Is this possible?

like image 915
JaVadid Avatar asked Jan 02 '10 10:01

JaVadid


2 Answers

You can also try setting an layout algorithm for the same.It worked for me

webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); 
like image 162
DeRagan Avatar answered Oct 05 '22 16:10

DeRagan


Set the initial scale to 1. It then zooms in to fill the screen. Haven't tested how this works on really tall web sites (blog posts with lots of comments for example) but it's working on a Droid X and an HTC Aria with a standard web page.

WebView.setInitialScale(1); 

I'll continue testing with different web pages but so far this is the best solution I've got for this issue.

EDIT: Tested with an obscenely long web page on both Droid X and Aria and got positive results on both. Setting the initial scale to 0 seems to turn the whole thing off resulting in initial scale being 100. I'm happy with these results, hope this helps others struggling with this issue.

like image 32
cesarislaw Avatar answered Oct 05 '22 14:10

cesarislaw