【发布时间】:2019-07-29 16:50:45
【问题描述】:
简单地说,在网页视图中加载内容并点击文本字段后,我的应用拒绝调整大小或平移。
这是我的设置
我有一个包含多个片段的 Activity。这是片段容器的布局。
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- MAIN CONTENT -->
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" />
<RelativeLayout
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start">
<!-- ... -->
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
这是 webview 片段的布局。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/tbOnlinePayment"
layout="@layout/toolbar" />
<WebView
android:layout_below="@+id/tbOnlinePayment"
android:id="@+id/paymentWebView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ProgressBar
android:id="@android:id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
我的应用主题扩展 Theme.AppCompat.Light.DarkActionBar
我的尝试:
- 就像网上写的一样,我尝试了
android:windowSoftInputMode="adjustResize"和android:windowSoftInputMode="adjustPan"。 - 我知道在全屏模式下
android:windowSoftInputMode="adjustResize"不起作用,但我不会手动强制。我将应用的主题放在这里,因为也许有人知道这个主题以某种方式强制全屏显示。 - 基于上述假设,我在应用的主题中添加了
<item name="android:windowFullscreen">false</item>,但仍然没有结果。 - 将
webview包装在scrollview中。 - 将
webview的高度更改为wrap_content。 - 基本上浏览了大部分 SO 帖子和解决方案。
我想要什么:
我真的不在乎 webview 是否被调整大小或向上推。我想要的是键盘不隐藏输入字段。
【问题讨论】:
-
在 Android Manifest 文件中尝试“android:windowSoftInputMode="adjustResize”,并在您的 html DOM 中使用元标记“height=device-height”。
-
也可以试试 android:windowSoftInputMode="adjustNothing"
-
我也有
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"阻止adjustResize工作。仅使用android:theme="@android:style/Theme.NoTitleBar"使adjustResize工作。最终与这个答案一起工作:stackoverflow.com/a/14565884/221458
标签: android