SideSheetDialog

public class SideSheetDialog
extends AppCompatDialog

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


Base class for Dialogs styled as a side sheet.

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

Summary

Inherited constants

Public constructors

SideSheetDialog(Context context)
SideSheetDialog(Context context, int theme)

Public methods

void cancel()

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

SideSheetBehavior<? extends View> getBehavior()

Returns the behavior associated with this SideSheetDialog.

boolean isDismissWithSheetAnimationEnabled()

Returns whether dismissing will perform the swipe away animation on the sheet, rather than the window animation for the 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 setDismissWithSheetAnimationEnabled(boolean dismissWithAnimation)

Set whether to perform the swipe away animation on the sheet when dismissing, rather than the window animation for the dialog.

void setSheetEdge(int gravity)

Set the edge which the sheet should originate from.

Protected methods

void onCreate(Bundle savedInstanceState)
void onStart()

Inherited methods

Public constructors

SideSheetDialog

public SideSheetDialog (Context context)

Parameters
context Context

SideSheetDialog

public SideSheetDialog (Context context, 
                int theme)

Parameters
context Context

theme int

Public methods

cancel

public void cancel ()

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

The default animation to dismiss this dialog is a fade-out transition through a windowAnimation. Set setDismissWithSheetAnimationEnabled(boolean) to true if you want to utilize the sheet animation instead.

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

getBehavior

public SideSheetBehavior<? extends View> getBehavior ()

Returns the behavior associated with this SideSheetDialog. The behavior must always be a SideSheetBehavior; otherwise, this method will throw an IllegalStateException.

Returns
SideSheetBehavior<? extends View>

isDismissWithSheetAnimationEnabled

public boolean isDismissWithSheetAnimationEnabled ()

Returns whether dismissing will perform the swipe away animation on the sheet, rather than the window animation for the 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

setDismissWithSheetAnimationEnabled

public void setDismissWithSheetAnimationEnabled (boolean dismissWithAnimation)

Set whether to perform the swipe away animation on the sheet when dismissing, rather than the window animation for the dialog.

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

setSheetEdge

public void setSheetEdge (int gravity)

Set the edge which the sheet should originate from.

Note: This method should be called when the sheet is initialized, before it is shown. Runtime sheet edge changes are not supported.

Parameters
gravity int: the edge from which the sheet and its animations should originate.

Throws
IllegalStateException if the sheet is null or has already been laid out

Protected methods

onCreate

protected void onCreate (Bundle savedInstanceState)

Parameters
savedInstanceState Bundle

onStart

protected void onStart ()