BottomSheetDialog

public class BottomSheetDialog
extends AppCompatDialog

java.lang.Object
   ↳ android.app.Dialog
     ↳ androidx.activity.ComponentDialog
       ↳ androidx.appcompat.app.AppCompatDialog
         ↳ com.google.android.material.bottomsheet.BottomSheetDialog


Base class for Dialogs styled as a bottom sheet.

Edge to edge window flags are automatically applied if the R.attr.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

Inherited constants

Public constructors

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

Protected constructors

BottomSheetDialog(Context context, boolean cancelable, DialogInterface.OnCancelListener cancelListener)

Public methods

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...

BottomSheetBehavior<FrameLayout> getBehavior()
boolean getDismissWithAnimation()

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

boolean getEdgeToEdgeEnabled()

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

void onAttachedToWindow()
void onDetachedFromWindow()
void setCancelable(boolean cancelable)
void setCanceledOnTouchOutside(boolean cancel)
void setContentView(View view)
void setContentView(int layoutResId)
void setContentView(View view, ViewGroup.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 EdgeToEdgeUtils.setLightStatusBar(Window, boolean) instead

Protected methods

void onCreate(Bundle savedInstanceState)
void onStart()

Inherited methods

Public constructors

BottomSheetDialog

public BottomSheetDialog (Context context)

Parameters
context Context

BottomSheetDialog

public BottomSheetDialog (Context context, 
                int theme)

Parameters
context Context

theme int

Protected constructors

BottomSheetDialog

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

Parameters
context Context

cancelable boolean

cancelListener DialogInterface.OnCancelListener

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 ERROR(/#setDismissWithAnimation(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 BottomSheetBehavior.STATE_HIDDEN is set. This will enforce the swipe down animation before canceling this dialog.

getBehavior

public BottomSheetBehavior<FrameLayout> getBehavior ()

Returns
BottomSheetBehavior<FrameLayout>

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.

Returns
boolean

getEdgeToEdgeEnabled

public boolean getEdgeToEdgeEnabled ()

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

Returns
boolean

onAttachedToWindow

public void onAttachedToWindow ()

onDetachedFromWindow

public void onDetachedFromWindow ()

setCancelable

public void setCancelable (boolean cancelable)

Parameters
cancelable boolean

setCanceledOnTouchOutside

public void setCanceledOnTouchOutside (boolean cancel)

Parameters
cancel boolean

setContentView

public void setContentView (View view)

Parameters
view View

setContentView

public void setContentView (int layoutResId)

Parameters
layoutResId int

setContentView

public void setContentView (View view, 
                ViewGroup.LayoutParams params)

Parameters
view View

params ViewGroup.LayoutParams

setDismissWithAnimation

public void setDismissWithAnimation (boolean dismissWithAnimation)

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

Parameters
dismissWithAnimation boolean: True if swipe down animation should be used when dismissing.

setLightStatusBar

public static void setLightStatusBar (View view, 
                boolean isLight)

This method is deprecated.
use EdgeToEdgeUtils.setLightStatusBar(Window, boolean) instead

Parameters
view View

isLight boolean

Protected methods

onCreate

protected void onCreate (Bundle savedInstanceState)

Parameters
savedInstanceState Bundle

onStart

protected void onStart ()