Closed MrHuangZW closed 3 years ago
@MrHuangZW 不支持 BottomSheetDialogFragment。
我这边试过还是不行,而且我们ui是要dialog不全屏的,下面附上代码 public void onStart() { super.onStart(); Dialog dialog = getDialog(); if (dialog != null) { //设置点击外部可消失 dialog.setCanceledOnTouchOutside(true); //设置使软键盘弹出的时候dialog不会被顶起 Window win = dialog.getWindow(); dialog.setOnKeyListener(this); WindowManager.LayoutParams params = dialog.getWindow().getAttributes(); win.setSoftInputMode(params.SOFT_INPUT_ADJUST_NOTHING); //这里设置dialog的进出动画 win.setWindowAnimations(R.style.DialogBottomAnim); params.gravity = Gravity.BOTTOM; // 使用ViewGroup.LayoutParams,以便Dialog 宽度充满整个屏幕 params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.height = ViewGroup.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(params);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable());
final View view = getView();
view.post(new Runnable() {
@Override
public void run() {
View parent = (View) view.getParent();
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) (parent).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
BottomSheetBehavior mBottomSheetBehavior = (BottomSheetBehavior) behavior;
//设置高度
int height = Screen.getHeight(getContext()) - StatusBarUtil.getStatusBarHeight(getContext()) ;
mBottomSheetBehavior.setPeekHeight(height);
parent.setBackgroundColor(Color.TRANSPARENT);
}
});
}
}
请参考demo dialog
Androidx版本:否 PanelSwitchHelper版本:v1.3.10 手机型号: 华为 CAZ-TL 10 手机系统版本: Android 7.0 问题描述:在BottomSheetDialogFragment使用时,首次当弹出键盘时,输入框紧贴键盘,但接下来底部虚拟按键弹出与隐藏时输入框位置不贴键盘,