我的应用程序底部有一个垂直滑动的抽屉。当软键盘打开时,它会把抽屉的标签往上推,所以它位于键盘上方。实际上,我想让它保持在屏幕的底部,当键盘显示时,它会被隐藏起来。

有人遇到过这个问题吗?知道怎么修吗?


当前回答

试着用这个:

android:windowSoftInputMode="stateHidden|adjustPan"

其他回答

这对我来说是最好的方法

android:windowSoftInputMode="adjustNothing"

试一试!

您可以尝试动态添加此属性,通过将以下代码放在您的活动的onCreate方法中:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

这对我来说很管用,但那就是:

android:windowSoftInputMode="adjustPan"

没有。

没有一个对我有用,试试这个

 private void scrollingWhileKeyboard() {
    drawerlayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {

            Rect r = new Rect();
            try {
                drawerlayout.getWindowVisibleDisplayFrame(r);
                int screenHeight = drawerlayout.getRootView().getHeight();
                int keypadHeight = screenHeight - r.bottom;
                if (keypadHeight > screenHeight * 0.15) {
                    tabLayout.setVisibility(View.GONE);
                } else {
                    tabLayout.setVisibility(View.VISIBLE);
                }
            } catch (NullPointerException e) {

            }
        }
    });

}

到目前为止,答案并没有帮助我,因为我有一个按钮和textInput字段(并排)下面的textView一直被键盘隐藏,但这已经解决了我的问题:

android:windowSoftInputMode="adjustResize"

这些答案对我没有帮助。所以我试着这样做:

android:windowSoftInputMode="adjustResize"

这就像一个魅力,现在我的应用程序的头没有消失。它的平滑。