BottomSheetBehavior has been introduced in Android Design Support Library 23.2, however it does not dim the rest of the screen and does not block interaction with the rest of the UI. Is there anyway this can be achieved?
public class BottomSheetDimmedFragment extends BottomSheetDialogFragment {
public static final String TAG = BottomSheetDimmedFragment.class.getSimpleName();
@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
final View view = View.inflate(getContext(), R.layout.test, null);
dialog.setContentView(view);
return dialog;
}
public void show(final FragmentActivity fragmentActivity) {
show(fragmentActivity.getSupportFragmentManager(), TAG);
}
}
In your activity:
BottomSheetDimmedFragment sheet = new BottomSheetDimmedFragment();
sheet.show(this);
Now, you will have a dim and also when clicked on a dim the dialog will close.
Implementation taken from here.
Use the bottom sheet with a fragment instead of a view :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With