简而言之,在 WebView 中加载内容并点击文本字段后,我的应用拒绝调整大小或平移。
这是我的设置
我有一个包含多个 fragment 的 Activity 。这是带有 fragment 容器的布局。
<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 fragment 的布局。
<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 是调整大小还是向上推。我想要的是不隐藏输入字段的键盘。
最佳答案
我试过:
<activity
android:name="com.myapp.MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
adjustResize 解决了这个问题。
关于android - 软键盘不向上推 webview 内容也不调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29296967/