我的Bottomsheetdialog
自定义视图有EditText
,而EditText
滚动下方的工作表已关闭,如何禁用BottomSheetDialog
拖动。任何帮助赞赏。
答案 0 :(得分:2)
我可能会迟到,但对我来说效果很好:
@Override
public void setupDialog(final Dialog dialog, int style) {
super.setupDialog(dialog, style);
// This should do the job
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(true);
}
答案 1 :(得分:0)
简单的解决方案,它解决了我遇到的两个问题。
1-它阻止了拖动事件。
2-解决了listView滚动问题
CoordinatorLayout.Behavior<View> behavior;
View profile_config_layout_bottom_sheet = findViewById(R.id.list_view_audience_profile_config_layout);
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) profile_config_layout_bottom_sheet.getLayoutParams();
behavior = layoutParams.getBehavior();
assert behavior != null;
((BottomSheetBehavior<View>) behavior).addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_DRAGGING) {
((BottomSheetBehavior<View>) behavior).setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {}
});
显示对话框:
((BottomSheetBehavior) behavior).setState(BottomSheetBehavior.STATE_EXPANDED);