开发者

Fit the content of a WebView on Screen with Zoom suport

开发者 https://www.devze.com 2023-02-14 14:03 出处:网络
I\'m trying to embed a HTML5 page into my application. The content is greater than device, so I\'m zooming it with:

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 scre开发者_开发问答en 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.


Try this:

        web = (WebView) findViewById(R.id.webview);
        web.getSettings().setBuiltInZoomControls(true);
        web.getSettings().setSupportZoom(true); 
        web.getSettings().setUseWideViewPort(true);
        web.getSettings().setLoadWithOverviewMode(true);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号