使用Zoom suport使屏幕上的WebView内容适合 [英] Fit the content of a WebView on Screen with Zoom suport
本文介绍了使用Zoom suport使屏幕上的WebView内容适合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将HTML5页面嵌入到我的应用程序中.
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
这样,屏幕尺寸正确,但是内容太小,我需要对其进行缩放控制.我尝试了WebView的supportZoom(true),放大是正确的,但是缩小时,这没有达到我的初始比例.
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.
推荐答案
尝试一下:
web = (WebView) findViewById(R.id.webview);
web.getSettings().setBuiltInZoomControls(true);
web.getSettings().setSupportZoom(true);
web.getSettings().setUseWideViewPort(true);
web.getSettings().setLoadWithOverviewMode(true);
这篇关于使用Zoom suport使屏幕上的WebView内容适合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文