BottomSheetDialog

public class BottomSheetDialog


Base class for android.app.Dialogs styled as a bottom sheet.

Edge to edge window flags are automatically applied if the navigationBarColor is transparent or translucent and enableEdgeToEdge is true. These can be set in the theme that is passed to the constructor, or will be taken from the theme of the context (ie. your application or activity theme).

In edge to edge mode, padding will be added automatically to the top when sliding under the status bar. Padding can be applied automatically to the left, right, or bottom if any of `paddingBottomSystemWindowInsets`, `paddingLeftSystemWindowInsets`, or `paddingRightSystemWindowInsets` are set to true in the style.

For more information, see the component developer guidance and design guidelines.

Summary

Public fields

BottomSheetBehavior<FrameLayout>
boolean
boolean

Public constructors

BottomSheetDialog(Context context)
BottomSheetDialog(Context context, int theme)

Protected constructors

BottomSheetDialog(
    Context context,
    boolean cancelable,
    OnCancelListener cancelListener
)

Public methods

void

This function can be called from a few different use cases, including Swiping the dialog down or calling `dismiss()` from a `BottomSheetDialogFragment`, tapping outside a dialog, etc...

BottomSheetBehavior<FrameLayout>
boolean

Returns if dismissing will perform the swipe down animation on the bottom sheet, rather than the window animation for the dialog.

boolean

Returns if edge to edge behavior is enabled for this dialog.

void
void
void
setCancelable(boolean cancelable)
void
setCanceledOnTouchOutside(boolean cancel)
void
setContentView(int layoutResId)
void
setContentView(View view)
void
setContentView(View view, LayoutParams params)
void
setDismissWithAnimation(boolean dismissWithAnimation)

Set to perform the swipe down animation when dismissing instead of the window animation for the dialog.

static void
setLightStatusBar(View view, boolean isLight)

This method is deprecated.

use setLightStatusBar instead

Protected methods

void
onCreate(Bundle savedInstanceState)
void

Public fields

behavior

public BottomSheetBehavior<FrameLayout> behavior

dismissWithAnimation

public boolean dismissWithAnimation

edgeToEdgeEnabled

public boolean edgeToEdgeEnabled

Public constructors

BottomSheetDialog

public BottomSheetDialog(Context context)

BottomSheetDialog

public BottomSheetDialog(Context context, int theme)

Protected constructors

BottomSheetDialog

protected BottomSheetDialog(
    Context context,
    boolean cancelable,
    OnCancelListener cancelListener
)

Public methods

cancel

public void cancel()

This function can be called from a few different use cases, including Swiping the dialog down or calling `dismiss()` from a `BottomSheetDialogFragment`, tapping outside a dialog, etc...

The default animation to dismiss this dialog is a fade-out transition through a windowAnimation. Call setDismissWithAnimation with `true` if you want to utilize the BottomSheet animation instead.

If this function is called from a swipe down interaction, or dismissWithAnimation is false, then keep the default behavior.

Else, since this is a terminal event which will finish this dialog, we override the attached BottomSheetBehavior.BottomSheetCallback to call this function, after STATE_HIDDEN is set. This will enforce the swipe down animation before canceling this dialog.

getBehavior

public BottomSheetBehavior<FrameLayout> getBehavior()

getDismissWithAnimation

public boolean getDismissWithAnimation()

Returns if dismissing will perform the swipe down animation on the bottom sheet, rather than the window animation for the dialog.

getEdgeToEdgeEnabled

public boolean getEdgeToEdgeEnabled()

Returns if edge to edge behavior is enabled for this dialog.

onAttachedToWindow

public void onAttachedToWindow()

onDetachedFromWindow

public void onDetachedFromWindow()

setCancelable

public void setCancelable(boolean cancelable)

setCanceledOnTouchOutside

public void setCanceledOnTouchOutside(boolean cancel)

setContentView

public void setContentView(int layoutResId)

setContentView

public void setContentView(View view)

setContentView

public void setContentView(View view, LayoutParams params)

setDismissWithAnimation

public void setDismissWithAnimation(boolean dismissWithAnimation)

Set to perform the swipe down animation when dismissing instead of the window animation for the dialog.

Parameters
boolean dismissWithAnimation

True if swipe down animation should be used when dismissing.

setLightStatusBar

public static void setLightStatusBar(View view, boolean isLight)

Protected methods

onCreate

protected void onCreate(Bundle savedInstanceState)

onStart

protected void onStart()