material-components_materia.../docs/components/BottomSheetDialogFragment.md
travisc ab2fec6da4 Move lib/src/ to lib/java/, and lib/jvmtests/javatests/ to lib/javatests/.
Bazel is happier if Java/Java test roots are named 'java' and 'javatests', and
this will mean that once we create a BUILD file for
android/support/design/{widget,internal}/ we'll no longer need a custom package
specified in our build (which tends to cause build problems that manifest quite
weirdly). This commit doesn't attempt to refactor the build at all yet, and is
just a pure move.

PiperOrigin-RevId: 178060739
2018-01-11 10:50:18 -05:00

2.9 KiB

Modal Bottom Sheets

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.

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.

Note: To implement non-modal Persistent bottom sheets use BottomSheetBehavior in conjunction with a CoordinatorLayout.

Design & API Documentation

Usage

  1. Subclass BottomSheetDialogFragment
  2. Override onCreateView.
  3. Use one of the two versions of show to display the dialog. Notice BottomSheetDialogFragment is a subclass of AppCompatFragment, which means you need to use Activity.getSupportFragmentManager().

Note: Don't call setOnCancelListener or setOnDismissListener on a BottomSheetDialogFragment, instead you can override onCancel(DialogInterface) or onDismiss(DialogInterface) if necessary.

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.