Android 完全阻止 WebView 缩放

发布于 2024-10-15 10:04:56 字数 913 浏览 3 评论 0原文

我有一个 WebView,并且有以下代码:

webview.setInitialScale(75);

我还禁用了缩放:

webview.getSettings().setSupportZoom(false);

这两段代码都工作得很好,直到在 WebView 中选择任何类型的文本框(输入字段),然后应用程序缩放到 100%。

我试图弄清楚如何在选择文本框时拦截并阻止比例发生,但是我对以下内容没有运气:

onCheckIsTextEditor() - 单击文本框时这似乎不会触发

我可以页面缩放后,通过覆盖 onScaleChanged( ) WebViewClient 类中的方法。但是,这只能通过循环 zoomOut() 方法,直到达到适当的比例。

对我来说,似乎必须有一个位置,单击实际上会触发事件来聚焦文本框并重绘视图以缩放它(并且调用 onScaleChanged() ),我只是无法还没有找到它。

任何帮助将不胜感激。

I have a WebView, and I have the following code:

webview.setInitialScale(75);

I also have zooming disabled:

webview.getSettings().setSupportZoom(false);

Both of these pieces of code work very well until any sort of textbox (input field) is selected within the WebView, then the application scales to 100%.

I'm trying to figure out how to intercept and stop the scale from taking place when a textbox is selected, however I've had no luck with the following:

onCheckIsTextEditor() - This doesn't seem to fire when the textbox is clicked

I can change the Scale back to 75% after the page scales by Overriding the onScaleChanged() method within the WebViewClient class. However this can only be done by looping through with the zoomOut() method until the proper scale is met.

To me it seems there must be a location where the click actually fires the event to focus the textbox and redraw the view to scale it (and onScaleChanged() is called), I just haven't been able to locate it yet.

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文