You can realize a modal bottom sheets using a BottomSheetDialogFragment
.
The BottomSheetDialogFragment
is a modal bottom sheet.
This is a version of DialogFragment
that shows a bottom sheet using BottomSheetDialog
instead of a floating dialog.
Just define the fragment:
public class MyBottomSheetDialogFragment extends BottomSheetDialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.my_fragment_bottom_sheet, container);
}
}
Then use this code to show the fragment:
MyBottomSheetDialogFragment mySheetDialog = new MyBottomSheetDialogFragment();
FragmentManager fm = getSupportFragmentManager();
mySheetDialog.show(fm, "modalSheetDialog");
This Fragment will create a BottomSheetDialog
.