选择文本字段时防止缩放

发布于 2024-12-29 11:16:21 字数 1342 浏览 1 评论 0原文

当选择文本框进行输入时,是否可以强制 android 不放大?我编写了一个 html5 Web 应用程序,在单击文本字段输入文本之前,布局看起来很棒。执行此操作后,Android 将自动放大文本字段。有办法防止这种情况吗?谢谢!

我的 webview 代码如下:

WebView myWebView = (WebView) findViewById(R.id.webview);
WebViewClient wv = new WebViewClient();
wv.shouldOverrideUrlLoading(myWebView, "http://urlgoeshere");
myWebView.setInitialScale(1);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setBuiltInZoomControls(false);
myWebView.getSettings().setLoadsImagesAutomatically(true);
myWebView.getSettings().setUseWideViewPort(true);
myWebView.getSettings().setDefaultZoom(ZoomDensity.FAR);
myWebView.getSettings().setSupportZoom(false);
myWebView.getSettings().setDomStorageEnabled(true);
myWebView.setWebViewClient(wv);
myWebView.loadUrl("http://urlgoeshere");

我的 webview xml 如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <WebView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview"

        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</RelativeLayout>

Is it possible to force android not to zoom in when a text box is selected for typing? I have written an html5 web app and the layouts look great until I click on the textfield to enter text. Upon this action, android will automatically zoom in on the textfield. Is there a way to prevent this? Thanks!

My code for the webview is as follows:

WebView myWebView = (WebView) findViewById(R.id.webview);
WebViewClient wv = new WebViewClient();
wv.shouldOverrideUrlLoading(myWebView, "http://urlgoeshere");
myWebView.setInitialScale(1);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setBuiltInZoomControls(false);
myWebView.getSettings().setLoadsImagesAutomatically(true);
myWebView.getSettings().setUseWideViewPort(true);
myWebView.getSettings().setDefaultZoom(ZoomDensity.FAR);
myWebView.getSettings().setSupportZoom(false);
myWebView.getSettings().setDomStorageEnabled(true);
myWebView.setWebViewClient(wv);
myWebView.loadUrl("http://urlgoeshere");

My xml for the webview is as follows:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <WebView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview"

        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</RelativeLayout>

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

姐不稀罕 2025-01-05 11:16:21

如果不需要,请尝试删除 setDefaultZoom()。这样您的程序就会将其留给手机来适应页面,并且不会强制放大

Try removing the setDefaultZoom() if that's not necessary. That way your program leaves it to the phone to accommodate the page and won't force zoom-in

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文