How to disable BottomSheetDialogFragment
dragging by finger?
I saw similar questions, but they\'re all about BottomSheet
not BottomSheetD
Simple solution
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) {}
});
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//Disable dragging by set isDraggable to false
val bottomSheetDialog = dialog as BottomSheetDialog
val bottomSheetBehavior = bottomSheetDialog.behavior
bottomSheetBehavior.isDraggable = false
}