本文介绍了设置变焦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 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);
这篇关于设置变焦web视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!