android - 软键盘不向上推 webview 内容也不调整大小

标签 android

简而言之,在 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>应用的主题,但仍然没有结果。
  • 包装webviewscrollview .
  • 更改 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/

相关文章:

android - 在自定义 Runnable 中使用 Retrofit 执行请求

android - 在代码中创建新参数不起作用?

java - Android Volley 请求抛出空指针异常

java - Google Play 可以根据操作系统进行过滤吗

android - 如何将从服务器获取的值存储在 Android Manifest 的元数据标记中

Android BackupManager 和我的应用程序数据库 : best approaches

java - 如何确保一个按钮只被点击了 "n"次?!机器人工作室

java构造函数不能应用于给定类型android studio

android - 可绘制的android XML周围出现奇怪的黑色边框

android - 调试 Android 应用程序?