设置变焦web视图视图、变焦、web

由网友(三道杠骚年)分享简介:我有一个web视图和2个网址,打开它。我想要做的是,当我设置为1号网址缩放级别,然后我去第2个URL,它也应该有相同的缩放级别。眼下,缩放级别重置为。I have a WebView and 2 urls to open it it. What I want to do is, when i set a zoom l...

我有一个web视图和2个网址,打开它。我想要做的是,当我设置为1号网址缩放级别,然后我去第2个URL,它也应该有相同的缩放级别。眼下,缩放级别重置为。

I have a WebView and 2 urls to open it it. What I want to do is, when i set a zoom level for 1st url, and then i go to 2nd url, it should also have the same zoom level. Right now, the zoom level resets for both.

谢谢, 法哈

推荐答案

使用 webSettings 类

webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);

请注意,虽然 webSettings 是可用,因为API级别1,WebSettings.ZoomDensity可因为API级别7.非常适用于所有的设备分辨率。

Notice that although webSettings is available since API Level 1, WebSettings.ZoomDensity is available since API Level 7. Works well for all device resolutions.

此外,为了在web视图允许缩放,添加以下code:

Also, in order to enable zoom on the webView, add the following code:

webView.getSettings().setBuiltInZoomControls(true);
阅读全文

相关推荐

最新文章