在Android中,当您弹出一个对话框时,它背后的屏幕会变暗.有没有办法控制看起来像什么?例如,使它或多或少变暗或使用某种模式?
我正在BottomSheetDialogFragment满足我的要求是创建底部菜单,如果我在片段区域外单击,则不应取消对话框并应保留。
问题: 片段外的事件应传播到较低的片段视图/片段。
我已经在下面尝试过(不适用于BottomDialogFragment): Allow external touch for DialogFragment
要停止对话框中取消我尝试下面(我称之为setCancelable(boolean)在onStart()BottomDialogFragment的):
@Override
public void setCancelable(boolean cancelable) {
super.setCancelable(cancelable);
BottomSheetDialog dialog = (BottomSheetDialog) getDialog();
dialog.setCanceledOnTouchOutside(cancelable);
View bottomSheetView = dialog.getWindow().getDecorView().findViewById(R.id.design_bottom_sheet);
BottomSheetBehavior.from(bottomSheetView).setHideable(cancelable);
}
Run Code Online (Sandbox Code Playgroud)
编辑:发现它很难,没有其他方法然后使用坐标布局。BottomSheetDialog 的最佳解决方案是here