gpt4 book ai didi

android - Android 应用程序中 WebView 中的 html 文本字段被软键盘隐藏

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:20:49 26 4
gpt4 key购买 nike

我有一个 Android 应用程序,它是一个带有 WebView 的 TabHost。我用它来加载底部有文本字段的特定 html 文件。

当我触摸 html 文本框时,软键盘会弹出,并隐藏文本框,这样我就看不到我输入的内容了。

这是布局:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TabWidget
android:focusableInTouchMode="false"
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="63dp" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>

我尝试使用 android:windowSoftInputMode="adjustResize" 配置 AndroidManifest.xml 文件,但没有成功。我还尝试用 ScollView 替换布局中的 FrameLayout,但这导致我的 webview 在应用程序运行时无限增加大小。 . 这可能是由于我在页面上运行了一些 javascript。

我注意到android的网络浏览器有一个漂亮的行为——在网页中,弹出软键盘后,网页平滑滚动,以便用户可以看到可聚焦的文本字段。我的应用程序怎么会有这种行为?

最佳答案

我快疯了,什么都不起作用 android:windowSoftInputMode="adjustResize" 可能有帮助,但请确保您的应用不是全屏模式。

为我的应用移除全屏解决了使用软键盘调整布局大小的问题。

<item name="android:windowFullscreen">false</item>

关于android - Android 应用程序中 WebView 中的 html 文本字段被软键盘隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2729932/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com