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

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


当前回答

@manifest在你的活动中:

android:windowSoftInputMode="stateAlwaysHidden|adjustPan"

其他回答

这对我来说是最好的方法

android:windowSoftInputMode="adjustNothing"

试一试!

只需要添加一行…

添加android:windowSoftInputMode="stateHidden|adjustPan"在必需的活动你的manifest文件。

我刚被解决了:):)

当你想隐藏视图时,打开键盘。

将此添加到您的活动清单文件

android:windowSoftInputMode="stateHidden|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) {

            }
        }
    });

}

@manifest在你的活动中:

android:windowSoftInputMode="stateAlwaysHidden|adjustPan"