Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fit the content of a WebView on Screen with Zoom suport

I'm trying to embed a HTML5 page into my application.

The content is greater than device, so I'm zooming it with:

web.setInitialScale((int) (728 / 600 * 100)); //728 is the height of the page, 600 of the device

This way the screen is in the correct size, but the content is too small, and I need to have zoom control on it. I tried the supportZoom(true) of the WebView, the zoom IN is correctly, but when zooming out, this doesn't reach my initial scale.

like image 403
Marcos Vasconcelos Avatar asked Nov 28 '22 03:11

Marcos Vasconcelos


1 Answers

Try this:

        web = (WebView) findViewById(R.id.webview);
        web.getSettings().setBuiltInZoomControls(true);
        web.getSettings().setSupportZoom(true); 
        web.getSettings().setUseWideViewPort(true);
        web.getSettings().setLoadWithOverviewMode(true);
like image 58
Whatzit Toya Avatar answered Dec 09 '22 18:12

Whatzit Toya