views:

1913

answers:

9

Hi Friend... a simple question... 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 doesnt need to scroll... IS it possible????

+1  A: 

Have you tried just calling WebView.zoomOut() repeatedly until it returns false?

Also, I would note that this technique you want to use really relies on the web page being quite short. If the page is long and you zoom out to fit it entirely on screen, the user is going to need very good eye sight! ;)

Christopher
hey thanx... havent checked it yet but i guess i will try it once im over with certain formalities here... Thanx a lot...
JaVadid
A: 

Hi,

I've tried with this:

WebView.zoomOut() repeatedly until it returns false

but it doesn't work on Android > 2.0. Any other ideas guys?

Thank you,

A: 

Hi,

I've the same problem. I can't fit the WebView to screen.

I tried WebView.zoomOut() but it didn't work on Android 2.1

I found a solution like this:

WebView.getSettings().setDefaultZoom(ZoomDensity.FAR);

But it isn't enough to fit my WebView to screen.

Any ideas??

yalçın
A: 

@user289751, yalçın

well friends as "Christopher" mentioned, zooming out too much is not something the user would like coz it'll reduce the legibility of the content shown...

rather i would like to suggest a alternate... its better u try setting the zoom controls... don know if they'll work in 2.1 or not...

webview.getSettings().setBuiltInZoomControls(true);

hope this solves ur problem... coz now u r giving user the control to change the zoom level...

JaVadid
A: 

I got this to work in a dialog using WRAP_CONTENT for both dimensions of the WebView, unfortunately when the web page becomes too large the webview pushes all my other widgets off the screen.

Android's layout system is pretty damn unintuitive!

Timmmm
You cant say that! You have used WRAP_CONTENT, if u need it to stay the same size and not change according to the size of the webpage then why not define its height and width... This will AFAIK solve ur problem!
JaVadid
A: 

I have a problem too with webkit. I am trying to make it take half the screen of my app cause I have widgets with information on the top but it just opens in a new browser which takes all the screen. Is there a way to make it smaller? I have tried alot of combination with the layouts etc but with no luck...

spagi
A: 

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

webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
Rahul
This still crashes on android os version below 2.2.http://code.google.com/p/android/issues/detail?id=5024
M.A. Cape
A: 

webview.setInitialScale(number);

where the higher 'number' is, the more zoomed in your page will be. start with lower numbers ( like 10) and adjust to taste

smoothwalsh
A: 

surround your webview by scrollview and the bottom widgets should appear

ali