# BottomSheetDialog

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/bottomsheet/BottomSheetDialog.java)

*** ** * ** ***


```
public class BottomSheetDialog
```

<br />

*** ** * ** ***

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](https://github.com/material-components/material-components-android/blob/master/docs/components/BottomSheet.md) and [design guidelines](https://material.io/components/bottom-sheets/overview).

## Summary

| ### Public fields |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior<FrameLayout>` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#behavior()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#dismissWithAnimation()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#edgeToEdgeEnabled()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#BottomSheetDialog(Context)(Context context)` |
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#BottomSheetDialog(Context,int)(Context context, int theme)` |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#BottomSheetDialog(Context,boolean,OnCancelListener)( Context context, boolean cancelable, OnCancelListener cancelListener )` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#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... |
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior<FrameLayout>` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#getBehavior()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#getDismissWithAnimation()()` Returns if dismissing will perform the swipe down animation on the bottom sheet, rather than the window animation for the dialog. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#getEdgeToEdgeEnabled()()` Returns if edge to edge behavior is enabled for this dialog. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#onAttachedToWindow()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#onDetachedFromWindow()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#setCancelable(boolean)(boolean cancelable)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#setCanceledOnTouchOutside(boolean)(boolean cancel)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#setContentView(int)(int layoutResId)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#setContentView(View)(View view)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#setContentView(View,ViewGroup.LayoutParams)(View view, LayoutParams params)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#setDismissWithAnimation(boolean)(boolean dismissWithAnimation)` Set to perform the swipe down animation when dismissing instead of the window animation for the dialog. |
| `static void` | `[setLightStatusBar](https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#setLightStatusBar(View,boolean))(View view, boolean isLight)` **This method is deprecated.** use `https://developer.android.com/reference/com/google/android/material/internal/EdgeToEdgeUtils#setLightStatusBar(Window,boolean)` instead <br /> |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#setProtections(java.util.List<Protection>)(https://developer.android.com/reference/java/util/List<Protection> protections)` Set the Protections applied to this BottomSheetDialog. |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#onCreate(Bundle)(Bundle savedInstanceState)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#onStart()()` |

## 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 `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#setDismissWithAnimation(boolean)` 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 `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.BottomSheetCallback` to call this function, after `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#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](https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialog#setLightStatusBar(View,boolean))(View view, boolean isLight)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/com/google/android/material/internal/EdgeToEdgeUtils#setLightStatusBar(Window,boolean)` instead

### setProtections

```
public void setProtections(List<Protection> protections)
```

Set the Protections applied to this BottomSheetDialog.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List<Protection> protections` | the list of Protections to apply. This value will override the existing Protections. An empty list will clear the Protections. |

## Protected methods

### onCreate

```
protected void onCreate(Bundle savedInstanceState)
```

### onStart

```
protected void onStart()
```