草庐IT

android - 为什么android :windowSoftInputMode ="stateVisible|adjustResize" adjust the screen when soft keyboard is shown?没有

coder 2023-12-16 原文

我似乎无法使 android:windowSoftInputMode="stateVisible|adjustResize"选项起作用。 当软键盘显示时, ScrollView 不会自动滚动到底部。

编辑:我尝试改用 adjustPan (stateVisible|adjustPan),但是 ScrollView 被禁用了。

解决方案:最后,我找到了一个可行的建议。我创建了一个 OnGlobalLayoutListener() 并将其添加到我的 ScrollView 中。我检查了我的 Activity 的 Root View (这是我的 ScrollView )的高度是否改变了。如果是,我假设显示了软键盘。

点击here了解更多信息。

这是我的源代码:

AndroidManifest.xml

<application
        ...
        android:theme="@android:style/Theme.NoTitleBar" >
        <activity
            ...
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateVisible|adjustResize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

带键盘的登录屏幕 - ScrollView 不滚动

期望的结果

最佳答案

解决方案:最后,我找到了一个可行的建议。我创建了一个 OnGlobalLayoutListener() 并将其添加到我的 ScrollView 中。我检查了我的 Activity 的 Root View (这是我的 ScrollView )的高度是否改变了。如果是,我假设显示了软键盘。

点击here了解更多信息。

关于android - 为什么android :windowSoftInputMode ="stateVisible|adjustResize" adjust the screen when soft keyboard is shown?没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22141168/

有关android - 为什么android :windowSoftInputMode ="stateVisible|adjustResize" adjust the screen when soft keyboard is shown?没有的更多相关文章

随机推荐