BottomSheetDialogFragment扩展超出状态栏时,软键盘打开

问题描述 投票:0回答:1

我有一个框架布局RecyclerView顶级garvity和使用的EditText底部重心。当我打开软键盘的布局超出了状态栏。我想keybard推仅EditText上没有整体布局。这里是我的setupDialog方法:

public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);

    dialog.setContentView(bottomSheetBinding.getRoot());

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


    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {

            BottomSheetDialog d = (BottomSheetDialog) dialog;

            FrameLayout bottomSheet = (FrameLayout) d.findViewById(android.support.design.R.id.design_bottom_sheet);

            BottomSheetBehavior.from(bottomSheet)
                    .setState(BottomSheetBehavior.STATE_EXPANDED);
        }
    });
}

我试图adjustPan和adjustResize,但无法正常工作。

android bottom-sheet
1个回答
0
投票

您应该使用此行:dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

© www.soinside.com 2019 - 2024. All rights reserved.