首页 > 解决方案 > 片段视图下方的键盘

问题描述

这就是我想要 在此处输入图像描述的我正在使用BottomsheetFragment我想要的是键盘应该在视图下方。但在我的情况下,键盘与片段视图重叠。

这是我的 xml 文件在这里检查我的代码

and i am getting this output

重叠键盘

标签: android

解决方案


我已经创建了一个示例应用程序并在您提供的底页 xml 上进行了测试。通过添加 android:windowSoftInputMode="stateAlwaysHidden|adjustResize"清单文件确实有效。

所以清单文件如下所示。

  <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="stateAlwaysHidden|adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

或者,您也可以在 Activity 类的 onCreate 中动态设置此属性,如下所示

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

我在示例应用程序上尝试了两种方式


推荐阅读