I'm updating this CL as I go to fix all the issue we can find. * Icon lists items now use correct icons, and are rearranged to be consistent. * Removed HTML comments that were interfering with the Liquid templates. * Added the benefits list to the docsite-index. * Capitalized "Design" in Material Design. * Spec links in icon list now use consistent labels. * URLs, headings and page titles are now internally consistent within the platform. PiperOrigin-RevId: 155445665
3.3 KiB
BottomSheetDialogFragment
Modal bottom sheets render a shadow on the content below them to indicate that they are modal, essentially a dialog. If the content outside of the dialog is tapped then the bottom sheet is dismissed. Modal bottom sheets can be dragged vertically and dismissed by completely sliding them down.
BottomSheetDialogFragment is a thin layer on top of the regular support library Fragment that renders your fragment as a modal bottom sheet, fundamentally acting as a dialog.
Note: To implement non-modal Persistent bottom sheets use BottomSheetBehavior in conjunction with a CoordinatorLayout.
Design & API Documentation
Usage
- Subclass BottomSheetDialogFragment
- Override
onCreateView. - Use one of the two versions of
showto display the dialog. Notice BottomSheetDialogFragment is a subclass of AppCompatFragment, which means you need to useActivity.getSupportFragmentManager().
Note: Don't call setOnCancelListener or setOnDismissListener on a
BottomSheetDialogFragment, instead you can override onCancel(DialogInterface)
or onDismiss(DialogInterface) if necessary.
Related Concepts
BottomSheetDialogFragments are a more modern version of Dialogs. They have a nicer-looking entrance animation and since they are pinned to the bottom they may feel easier to use on larger devices.
BottomSheetDialogFragments look very similar to the effects of BottomSheetBehavior but the latter is not modal and requires a CoordinatorLayout.