I want to prevent dialog dismissing and response touch event behide the dialog when I touch outside of the BottomSheetDialogFragment, so I do like this in my BottomSheetDialogFragment class:
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View dialogView = inflater.inflate(R.layout.poi_result_bottom_dialog, container, false);
this.getDialog().setCanceledOnTouchOutside(false);
return dialogView;
}
However, I find if I set 'setCanceledOnTouchOutside(false)', my activity under the dialog can't respond touch event when I touch outside of the dialog.
You should not be using a BottomSheetDialog
. What you want is referred as a Persistent Bottom Sheet. It is well described with instructions at androidhive.info by using an embedded View
, and setting up a BottomSheetBehavior
.