简体   繁体   中英

Webview zoom android 4.4

I have an app that uses webview to display a set of images. Here is an example of an url that I use: http://butek.nu/mattilbud/butikker/oslo/meny/

The problem with android 4.4 is that it is not possible to zoom on the images anymore.. Have tried reading a bit on here: http://developer.android.com/guide/webapps/migrating.html . The viewport is good, the images scales good, but not possible to zoom in any way.(double pinch or multigestures). Here are some of the settings on my webview:

    wv = (WebView) findViewById(R.id.webView1);
    wv.getSettings().setLoadWithOverviewMode(true);
    wv.getSettings().setUseWideViewPort(true);          
    wv.getSettings().setDomStorageEnabled(true);
    wv.getSettings().setSupportZoom(true);
    wv.getSettings().setBuiltInZoomControls(true);
    wv.getSettings().setDisplayZoomControls(false);

Tried with none of them and then putting one and one "on" again.

Any solutions? Thanks.

You may have the WebView's LayoutParams.height set to WRAP_CONTENT. This causes the viewport width to be recalculated at the end of every pinch zoom. Because you have your images set to be width:100%, after pinch-zoom they resize back to being as wide as the viewport.

Per the WebView documentation - you should not be mixing WRAP_CONTENT and pinch-zooming. Set the WebView's layoutParams to something other than WRAP_CONTENT and this should work fine.

If I'm guessing incorrectly and you still have problems try removing the img { width:100%; } img { width:100%; } CSS rule.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM