Based on DialogFragment document
https://developer.android.com/reference/android/support/v4/app/DialogFragment.html#setCancelable(boolean)
Control whether the shown Dialog is cancelable. Use this instead of directly calling Dialog.setCancelable(boolean)
, because DialogFragment needs to change its behavior based on this.
Params:
cancelable – If true, the dialog is cancelable. The default is true.
You may try this :
In Kotlin
val switchAccountBottomSheet = SwitchAccountBottomSheet()
switchAccountBottomSheet.isCancelable = false
switchAccountBottomSheet.show(getActivity().getSupportFragmentManager(), SwitchAccountBottomSheet.class.getName());
In Java
SwitchAccountBottomSheet mSwitchAccountBottomSheet = new SwitchAccountBottomSheet();
mSwitchAccountBottomSheet.setCancelable(false);
mSwitchAccountBottomSheet.show(getActivity().getSupportFragmentManager(), SwitchAccountBottomSheet.class.getName());