Open BottomSheet DialogFragment in Expanded mode by default.
suggest changeA BottomSheetDialogFragment opens in STATE_COLLAPSED by default. It can be forced to STATE_EXPANDED, taking the full screen, with the following code:
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
BottomSheetDialog d = (BottomSheetDialog) dialog;
FrameLayout bottomSheet = (FrameLayout) d.findViewById(android.support.design.R.id.design_bottom_sheet);
BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
// Do something with your dialog like setContentView() or whatever
return dialog;
}
The dialog animation is slightly noticeable, but the fragment opens full screen.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents