单击 WebView 中的表单字段时禁用缩放? [英] Disable zoom when clicking on form fields within a WebView?

查看:16
本文介绍了单击 WebView 中的表单字段时禁用缩放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有类似的问题,我已经翻阅了几十页,但没有一个有任何答案,所以希望这个问题会有所不同.

I've looked through dozens of pages if similar questions, none of them have any answers, so hopefully this one will be different.

我有一个 webview,我不希望视图的缩放比例从我设置的初始缩放级别改变.当前唯一改变缩放级别的是文本框聚焦时.

I have a webview, and I do not want the zoom of the view to change from the initial zoom level I have it set to. The only thing which changes the zoom level currently is when a text box is focused.

我需要能够通过 Java 代码做到这一点,而不是使用视口元标记.

I need to be able to do this through Java code, not using the viewport meta tag.

只是为了我没有常见的反应,我的代码中有以下内容来禁用缩放和缩放控件:

Just so I don't have the common responses, I have the following in my code to disable zooming, and the zoom controls:

mWebView.getSettings().setBuiltInZoomControls(false);
mWebView.getSettings().setSupportZoom(false);

我认为一个可能的解决方案是检查 WebView 中何时发生 onFocus 甚至 onClick 事件,然后缩小,但我什至不确定这是否可能?

I'm thinking that a possible solution is to check to see when an onFocus or even an onClick event occurs within the WebView and then zoomOut, but I'm not even sure if that is possible?

如有任何建议,我们将不胜感激.

Any suggestions would be appreciated.

推荐答案

此问题已通过 HTC 设备上的固件更新修复,它(显然)是由 Sense UI 错误地覆盖默认 Android 功能引起的.

This issue has been fixed by a firmware update on HTC devices, it was (apparently) being caused by the Sense UI overriding default Android functionality incorrectly.

很难提供有关何时更正此问题的确切信息,但是当在具有最新固件的任何 HTC 设备上单击文本框时,我的 Web 应用程序不再缩放.

It is very difficult to provide information on exactly when this was corrected, however my web application no longer zooms when a text box is clicked on any HTC device with the latest firmware.

以下两行代码将禁用 android webview 的缩放"方面:

The following two lines of code will disable the "zoom" aspects of an android webview:

// disables the actual onscreen controls from showing up
mWebView.getSettings().setBuiltInZoomControls(false);
// disables the ability to zoom
mWebView.getSettings().setSupportZoom(false);

这篇关于单击 WebView 中的表单字段时禁用缩放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆