# BottomSheetBehavior

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

*** ** * ** ***


```
public class BottomSheetBehavior<V extends View>
```

<br />

*** ** * ** ***

An interaction behavior plugin for a child view of CoordinatorLayout to make it work as a bottom sheet.

To send useful accessibility events, set a title on bottom sheets that are windows or are window-like. For BottomSheetDialog use setTitle, and for BottomSheetDialogFragment use setAccessibilityPaneTitle.

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

| ### Nested types |
|---|
| `public abstract class https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.BottomSheetCallback` Callback for monitoring events about bottom sheets. |
| `protected class https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.SavedState` State persisted across instances |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#PEEK_HEIGHT_AUTO() = -1` Peek at the 16:9 ratio keyline of its parent. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_ALL() = -1` This flag will preserve all aforementioned values on configuration change. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_FIT_TO_CONTENTS() = 2` This flag will preserve the fitToContents boolean value on configuration change. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_HIDEABLE() = 4` This flag will preserve the hideable boolean value on configuration change. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_NONE() = 0` This flag will not preserve the aforementioned values set at runtime if the view is destroyed and recreated. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_PEEK_HEIGHT() = 1` This flag will preserve the peekHeight int value on configuration change. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_SKIP_COLLAPSED() = 8` This flag will preserve the skipCollapsed boolean value on configuration change. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_COLLAPSED() = 4` The bottom sheet is collapsed. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_DRAGGING() = 1` The bottom sheet is dragging. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_EXPANDED() = 3` The bottom sheet is expanded. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_HALF_EXPANDED() = 6` The bottom sheet is half-expanded (used when fitToContents is false). |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_HIDDEN() = 5` The bottom sheet is hidden. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_SETTLING() = 2` The bottom sheet is settling. |

| ### Public fields |
|---|---|
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#expandedOffset()` |
| `float` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#halfExpandedRatio()` |
| `float` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#hideFriction()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#maxHeight()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#maxWidth()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#peekHeight()` Peek height set by the user. |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#saveFlags()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#significantVelocityThreshold()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#skipCollapsed()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#state()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#BottomSheetBehavior()()` |
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#BottomSheetBehavior(Context,AttributeSet)(Context context, AttributeSet attrs)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#addBottomSheetCallback(com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback)( https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.BottomSheetCallback callback )` Adds a callback to be notified of bottom sheet events. |
| `float` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#calculateSlideOffset()()` Calculates the current offset of the bottom sheet. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#cancelBackProgress()()` Call this method from onBackCancelled or handleOnBackCancelled so that the back handler can cancel the back animation. |
| `static https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior<V>` | `<V extends View> https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#from(V)(V view)` A utility function to get the `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior` associated with the `view`. |
| `static Protection` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getDefaultBottomGradientProtection(Context)(Context context)` Returns a default GradientProtection for use with BottomSheets. |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getExpandedOffset()()` Returns the current expanded offset. |
| `float` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getHalfExpandedRatio()()` Gets the ratio for the height of the BottomSheet in the `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_HALF_EXPANDED()` state. |
| `float` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getHideFriction()()` Gets the friction coefficient to hide the bottom sheet, or set it to the next closest expanded state. |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getMaxHeight()()` Returns the bottom sheet's maximum height, or -1 if no maximum height is set. |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getMaxWidth()()` Returns the bottom sheet's maximum width, or -1 if no maximum width is set. |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getPeekHeight()()` Gets the height of the bottom sheet when it is collapsed. |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getSaveFlags()()` Returns the save flags. |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getSignificantVelocityThreshold()()` Returns the significant velocity threshold. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getSkipCollapsed()()` Sets whether this bottom sheet should skip the collapsed state when it is being hidden after it is expanded once. |
| `int` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getState()()` Gets the current state of the bottom sheet. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#handleBackInvoked()()` Call this method from onBackInvoked or handleOnBackPressed so that the back handler can complete the back animation, or handle back without progress in certain cases. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#isAutoExpandOnRequestChildRectangleOffscreen()()` Gets whether the bottom sheet should automatically expand when one of its children requests to be on screen. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#isDraggable()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#isDraggableOnNestedScroll()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#isFitToContents()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#isGestureInsetBottomIgnored()()` Returns whether this bottom sheet should adjust it's position based on the system gesture area. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#isHideable()()` Gets whether this bottom sheet can hide when it is swiped down. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#isShouldRemoveExpandedCorners()()` Returns whether the bottom sheet will remove its corners when it reaches the expanded state. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onAttachedToLayoutParams(LayoutParams)(LayoutParams layoutParams)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onDetachedFromLayoutParams()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onInterceptTouchEvent(CoordinatorLayout,V,MotionEvent)( CoordinatorLayout parent, V child, MotionEvent event )` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onLayoutChild(CoordinatorLayout,V,int)(CoordinatorLayout parent, V child, int layoutDirection)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onMeasureChild(CoordinatorLayout,V,int,int,int,int)( CoordinatorLayout parent, V child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed )` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onNestedPreFling(CoordinatorLayout,V,View,float,float)( CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY )` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onNestedPreScroll(CoordinatorLayout,V,View,int,int,int[],int)( CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, int type )` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onNestedScroll(CoordinatorLayout,V,View,int,int,int,int,int,int[])( CoordinatorLayout coordinatorLayout, V child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, int[] consumed )` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onRequestChildRectangleOnScreen(CoordinatorLayout,V,Rect,boolean)( CoordinatorLayout coordinatorLayout, V child, Rect rectangle, boolean immediate )` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onRestoreInstanceState(CoordinatorLayout,V,Parcelable)( CoordinatorLayout parent, V child, Parcelable state )` |
| `Parcelable` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onSaveInstanceState(CoordinatorLayout,V)(CoordinatorLayout parent, V child)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onStartNestedScroll(CoordinatorLayout,V,View,View,int,int)( CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int axes, int type )` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onStopNestedScroll(CoordinatorLayout,V,View,int)( CoordinatorLayout coordinatorLayout, V child, View target, int type )` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#onTouchEvent(CoordinatorLayout,V,MotionEvent)(CoordinatorLayout parent, V child, MotionEvent event)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#removeBottomSheetCallback(com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback)( https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.BottomSheetCallback callback )` Removes a previously added callback. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setAutoExpandOnRequestChildRectangleOffscreen(boolean)( boolean autoExpandOnRequestChildRectangleOffscreen )` Sets whether the bottom sheet should automatically expand when one of its children requests to be on screen. |
| `void` | `[setBottomSheetCallback](https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setBottomSheetCallback(com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback))( https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.BottomSheetCallback callback )` **This method is deprecated.** use `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#addBottomSheetCallback(com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback)` and `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#removeBottomSheetCallback(com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback)` instead <br /> |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setDraggable(boolean)(boolean draggable)` Sets whether this bottom sheet can be collapsed/expanded by dragging. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setDraggableOnNestedScroll(boolean)(boolean draggableOnNestedScroll)` Sets whether this bottom sheet can be collapsed/expanded by dragging on the nested scrolling child view. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setExpandedOffset(int)(int offset)` Determines the top offset of the BottomSheet in the `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_EXPANDED()` state when fitsToContent is false. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setFitToContents(boolean)(boolean fitToContents)` Sets whether the height of the expanded sheet is determined by the height of its contents, or if it is expanded in two stages (half the height of the parent container, full height of parent container). |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setGestureInsetBottomIgnored(boolean)(boolean gestureInsetBottomIgnored)` Sets whether this bottom sheet should adjust it's position based on the system gesture area on Android Q and above. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setHalfExpandedRatio(float)(float ratio)` Determines the height of the BottomSheet in the `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_HALF_EXPANDED()` state. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setHideFriction(float)(float hideFriction)` Sets the friction coefficient to hide the bottom sheet, or set it to the next closest expanded state. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setHideable(boolean)(boolean hideable)` Sets whether this bottom sheet can hide. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setMaxHeight(int)(int maxHeight)` Sets the maximum height of the bottom sheet. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setMaxWidth(int)(int maxWidth)` Sets the maximum width of the bottom sheet. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setPeekHeight(int)(int peekHeight)` Sets the height of the bottom sheet when it is collapsed. |
| `final void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setPeekHeight(int,boolean)(int peekHeight, boolean animate)` Sets the height of the bottom sheet when it is collapsed while optionally animating between the old height and the new height. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setSaveFlags(int)(int flags)` Sets save flags to be preserved in bottomsheet on configuration change. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setShouldRemoveExpandedCorners(boolean)(boolean shouldRemoveExpandedCorners)` Sets whether the bottom sheet should remove its corners when it reaches the expanded state. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setSignificantVelocityThreshold(int)(int significantVelocityThreshold)` Sets the velocity threshold considered significant enough to trigger a slide to the next stable state. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setSkipCollapsed(boolean)(boolean skipCollapsed)` Sets whether this bottom sheet should skip the collapsed state when it is being hidden after it is expanded once. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setState(int)(int state)` Sets the state of the bottom sheet. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setUpdateImportantForAccessibilityOnSiblings(boolean)( boolean updateImportantForAccessibilityOnSiblings )` Sets whether the BottomSheet should update the accessibility status of its CoordinatorLayout siblings when expanded. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#startBackProgress(BackEventCompat)(BackEventCompat backEvent)` Call this method from onBackStarted or handleOnBackStarted so that the back handler can initialize and start animating. |
| `void` | `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#updateBackProgress(BackEventCompat)(BackEventCompat backEvent)` Call this method from onBackProgressed or handleOnBackProgressed so that the back handler can continue animating with a new progress value. |

## Constants

### PEEK_HEIGHT_AUTO

```
public static final int PEEK_HEIGHT_AUTO = -1
```

Peek at the 16:9 ratio keyline of its parent.

This can be used as a parameter for `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setPeekHeight(int)`. `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getPeekHeight()` will return this when the value is set.

### SAVE_ALL

```
public static final int SAVE_ALL = -1
```

This flag will preserve all aforementioned values on configuration change.

### SAVE_FIT_TO_CONTENTS

```
public static final int SAVE_FIT_TO_CONTENTS = 2
```

This flag will preserve the fitToContents boolean value on configuration change.

### SAVE_HIDEABLE

```
public static final int SAVE_HIDEABLE = 4
```

This flag will preserve the hideable boolean value on configuration change.

### SAVE_NONE

```
public static final int SAVE_NONE = 0
```

This flag will not preserve the aforementioned values set at runtime if the view is destroyed and recreated. The only value preserved will be the positional state, e.g. collapsed, hidden, expanded, etc. This is the default behavior.

### SAVE_PEEK_HEIGHT

```
public static final int SAVE_PEEK_HEIGHT = 1
```

This flag will preserve the peekHeight int value on configuration change.

### SAVE_SKIP_COLLAPSED

```
public static final int SAVE_SKIP_COLLAPSED = 8
```

This flag will preserve the skipCollapsed boolean value on configuration change.

### STATE_COLLAPSED

```
public static final int STATE_COLLAPSED = 4
```

The bottom sheet is collapsed.

### STATE_DRAGGING

```
public static final int STATE_DRAGGING = 1
```

The bottom sheet is dragging.

### STATE_EXPANDED

```
public static final int STATE_EXPANDED = 3
```

The bottom sheet is expanded.

### STATE_HALF_EXPANDED

```
public static final int STATE_HALF_EXPANDED = 6
```

The bottom sheet is half-expanded (used when fitToContents is false).

### STATE_HIDDEN

```
public static final int STATE_HIDDEN = 5
```

The bottom sheet is hidden.

### STATE_SETTLING

```
public static final int STATE_SETTLING = 2
```

The bottom sheet is settling.

## Public fields

### expandedOffset

```
public int expandedOffset
```

### halfExpandedRatio

```
public float halfExpandedRatio
```

### hideFriction

```
public float hideFriction
```

### maxHeight

```
public int maxHeight
```

### maxWidth

```
public int maxWidth
```

### peekHeight

```
public int peekHeight
```

Peek height set by the user.

### saveFlags

```
public int saveFlags
```

### significantVelocityThreshold

```
public int significantVelocityThreshold
```

### skipCollapsed

```
public boolean skipCollapsed
```

### state

```
public int state
```

## Public constructors

### BottomSheetBehavior

```
public BottomSheetBehavior()
```

### BottomSheetBehavior

```
public BottomSheetBehavior(Context context, AttributeSet attrs)
```

## Public methods

### addBottomSheetCallback

```
public void addBottomSheetCallback(
    BottomSheetBehavior.BottomSheetCallback callback
)
```

Adds a callback to be notified of bottom sheet events.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.BottomSheetCallback callback` | The callback to notify when bottom sheet events occur. |

### calculateSlideOffset

```
public float calculateSlideOffset()
```

Calculates the current offset of the bottom sheet. This method should be called when the child view is laid out.

| Returns |
|---|---|
| `float` | The offset of this bottom sheet within \[-1,1\] range. Offset increases as this bottom sheet is moving upward. From 0 to 1 the sheet is between collapsed and expanded states and from -1 to 0 it is between hidden and collapsed states. Returns -1 if the bottom sheet is not laid out (therefore it's hidden). |

### cancelBackProgress

```
public void cancelBackProgress()
```

Call this method from onBackCancelled or handleOnBackCancelled so that the back handler can cancel the back animation.

### from

```
public static BottomSheetBehavior<V> <V extends View> from(V view)
```

A utility function to get the `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior` associated with the `view`.

| Parameters |
|---|---|
| `V view` | The View with `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior<V>` | The `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior` associated with the `view`. |

### getDefaultBottomGradientProtection

```
public static Protection getDefaultBottomGradientProtection(Context context)
```

Returns a default GradientProtection for use with BottomSheets.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `R.attr.colorSurfaceContainerLow` and ` R.attr.colorSurface` are not set in the current theme. |

### getExpandedOffset

```
public int getExpandedOffset()
```

Returns the current expanded offset. If `fitToContents` is true, it will automatically pick the offset depending on the height of the content.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_expandedOffset

### getHalfExpandedRatio

```
public float getHalfExpandedRatio()
```

Gets the ratio for the height of the BottomSheet in the `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_HALF_EXPANDED()` state.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_halfExpandedRatio

### getHideFriction

```
public float getHideFriction()
```

Gets the friction coefficient to hide the bottom sheet, or set it to the next closest expanded state.

| Returns |
|---|---|
| `float` | The friction coefficient that determines the swipe velocity needed to hide or set the bottom sheet to the closest expanded state. |

### getMaxHeight

```
public int getMaxHeight()
```

Returns the bottom sheet's maximum height, or -1 if no maximum height is set.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_android_maxHeight

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setMaxHeight(int)` |   |

### getMaxWidth

```
public int getMaxWidth()
```

Returns the bottom sheet's maximum width, or -1 if no maximum width is set.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_android_maxWidth

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setMaxWidth(int)` |   |

### getPeekHeight

```
public int getPeekHeight()
```

Gets the height of the bottom sheet when it is collapsed.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_peekHeight

| Returns |
|---|---|
| `int` | The height of the collapsed bottom sheet in pixels, or `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#PEEK_HEIGHT_AUTO()` if the sheet is configured to peek automatically at 16:9 ratio keyline |

### getSaveFlags

```
public int getSaveFlags()
```

Returns the save flags.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_saveFlags

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setSaveFlags(int)` |   |

### getSignificantVelocityThreshold

```
public int getSignificantVelocityThreshold()
```

Returns the significant velocity threshold.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_significantVelocityThreshold

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setSignificantVelocityThreshold(int)` |   |

### getSkipCollapsed

```
public boolean getSkipCollapsed()
```

Sets whether this bottom sheet should skip the collapsed state when it is being hidden after it is expanded once.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_skipCollapsed

| Returns |
|---|---|
| `boolean` | Whether the bottom sheet should skip the collapsed state. |

### getState

```
public int getState()
```

Gets the current state of the bottom sheet.

| Returns |
|---|---|
| `int` | One of `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_EXPANDED()`, `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_HALF_EXPANDED()`, `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_COLLAPSED()`, `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_DRAGGING()`, or `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_SETTLING()`. |

### handleBackInvoked

```
public void handleBackInvoked()
```

Call this method from onBackInvoked or handleOnBackPressed so that the back handler can complete the back animation, or handle back without progress in certain cases.

### isAutoExpandOnRequestChildRectangleOffscreen

```
public boolean isAutoExpandOnRequestChildRectangleOffscreen()
```

Gets whether the bottom sheet should automatically expand when one of its children requests to be on screen. For example, if an off-screen child gains focus during input navigation (e.g., using tab or arrow keys) while the bottom sheet is collapsed, the sheet will expand to reveal the focused child, improving accessibility.

Internally, the behavior relies on `onRequestChildRectangleOnScreen`.

Only works on Android API level 36+.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_autoExpandOnRequestChildRectangleOffscreen

| Returns |
|---|---|
| `boolean` | `true` if it automatically expands. |

### isDraggable

```
public boolean isDraggable()
```

### isDraggableOnNestedScroll

```
public boolean isDraggableOnNestedScroll()
```

### isFitToContents

```
public boolean isFitToContents()
```

| Returns |
|---|---|
| `boolean` | whether the height of the expanded sheet is determined by the height of its contents, or if it is expanded in two stages (half the height of the parent container, full height of parent container). |

### isGestureInsetBottomIgnored

```
public boolean isGestureInsetBottomIgnored()
```

Returns whether this bottom sheet should adjust it's position based on the system gesture area.

### isHideable

```
public boolean isHideable()
```

Gets whether this bottom sheet can hide when it is swiped down.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_hideable

| Returns |
|---|---|
| `boolean` | `true` if this bottom sheet can hide. |

### isShouldRemoveExpandedCorners

```
public boolean isShouldRemoveExpandedCorners()
```

Returns whether the bottom sheet will remove its corners when it reaches the expanded state.

### onAttachedToLayoutParams

```
public void onAttachedToLayoutParams(LayoutParams layoutParams)
```

### onDetachedFromLayoutParams

```
public void onDetachedFromLayoutParams()
```

### onInterceptTouchEvent

```
public boolean onInterceptTouchEvent(
    CoordinatorLayout parent,
    V child,
    MotionEvent event
)
```

### onLayoutChild

```
public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection)
```

### onMeasureChild

```
public boolean onMeasureChild(
    CoordinatorLayout parent,
    V child,
    int parentWidthMeasureSpec,
    int widthUsed,
    int parentHeightMeasureSpec,
    int heightUsed
)
```

### onNestedPreFling

```
public boolean onNestedPreFling(
    CoordinatorLayout coordinatorLayout,
    V child,
    View target,
    float velocityX,
    float velocityY
)
```

### onNestedPreScroll

```
public void onNestedPreScroll(
    CoordinatorLayout coordinatorLayout,
    V child,
    View target,
    int dx,
    int dy,
    int[] consumed,
    int type
)
```

### onNestedScroll

```
public void onNestedScroll(
    CoordinatorLayout coordinatorLayout,
    V child,
    View target,
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int type,
    int[] consumed
)
```

### onRequestChildRectangleOnScreen

```
public boolean onRequestChildRectangleOnScreen(
    CoordinatorLayout coordinatorLayout,
    V child,
    Rect rectangle,
    boolean immediate
)
```

### onRestoreInstanceState

```
public void onRestoreInstanceState(
    CoordinatorLayout parent,
    V child,
    Parcelable state
)
```

### onSaveInstanceState

```
public Parcelable onSaveInstanceState(CoordinatorLayout parent, V child)
```

### onStartNestedScroll

```
public boolean onStartNestedScroll(
    CoordinatorLayout coordinatorLayout,
    V child,
    View directTargetChild,
    View target,
    int axes,
    int type
)
```

### onStopNestedScroll

```
public void onStopNestedScroll(
    CoordinatorLayout coordinatorLayout,
    V child,
    View target,
    int type
)
```

### onTouchEvent

```
public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent event)
```

### removeBottomSheetCallback

```
public void removeBottomSheetCallback(
    BottomSheetBehavior.BottomSheetCallback callback
)
```

Removes a previously added callback.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.BottomSheetCallback callback` | The callback to remove. |

### setAutoExpandOnRequestChildRectangleOffscreen

```
public void setAutoExpandOnRequestChildRectangleOffscreen(
    boolean autoExpandOnRequestChildRectangleOffscreen
)
```

Sets whether the bottom sheet should automatically expand when one of its children requests to be on screen. For example, if an off-screen child gains focus during input navigation (e.g., using tab or arrow keys) while the bottom sheet is collapsed, the sheet will expand to reveal the focused child, improving accessibility.

Internally, the behavior relies on `onRequestChildRectangleOnScreen`.

Only works on Android API level 36+.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_autoExpandOnRequestChildRectangleOffscreen

| Parameters |
|---|---|
| `boolean autoExpandOnRequestChildRectangleOffscreen` | `true` to automatically expand. |

### setBottomSheetCallback

```
public void [setBottomSheetCallback](https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#setBottomSheetCallback(com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback))(
    BottomSheetBehavior.BottomSheetCallback callback
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#addBottomSheetCallback(com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback)` and `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#removeBottomSheetCallback(com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback)` instead

Sets a callback to be notified of bottom sheet events.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior.BottomSheetCallback callback` | The callback to notify when bottom sheet events occur. |

### setDraggable

```
public void setDraggable(boolean draggable)
```

Sets whether this bottom sheet can be collapsed/expanded by dragging. Note: When disabling dragging, an app will require to implement a custom way to expand/collapse the bottom sheet

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_draggable

| Parameters |
|---|---|
| `boolean draggable` | `false` to prevent dragging the sheet to collapse and expand |

### setDraggableOnNestedScroll

```
public void setDraggableOnNestedScroll(boolean draggableOnNestedScroll)
```

Sets whether this bottom sheet can be collapsed/expanded by dragging on the nested scrolling child view. Default is true.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_draggableOnNestedScroll

| Parameters |
|---|---|
| `boolean draggableOnNestedScroll` | `false` to prevent dragging the nested scrolling child view to collapse and expand the sheet |

### setExpandedOffset

```
public void setExpandedOffset(int offset)
```

Determines the top offset of the BottomSheet in the `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_EXPANDED()` state when fitsToContent is false. The default value is 0, which results in the sheet matching the parent's top.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_expandedOffset

| Parameters |
|---|---|
| `int offset` | an integer value greater than equal to 0, representing the `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_EXPANDED()` offset. Value must not exceed the offset in the half expanded state. |

### setFitToContents

```
public void setFitToContents(boolean fitToContents)
```

Sets whether the height of the expanded sheet is determined by the height of its contents, or if it is expanded in two stages (half the height of the parent container, full height of parent container). Default value is true.

| Parameters |
|---|---|
| `boolean fitToContents` | whether or not to fit the expanded sheet to its contents. |

### setGestureInsetBottomIgnored

```
public void setGestureInsetBottomIgnored(boolean gestureInsetBottomIgnored)
```

Sets whether this bottom sheet should adjust it's position based on the system gesture area on Android Q and above.

Note: the bottom sheet will only adjust it's position if it would be unable to be scrolled upwards because the peekHeight is less than the gesture inset margins,(because that would cause a gesture conflict), gesture navigation is enabled, and this `ignoreGestureInsetBottom` flag is false.

### setHalfExpandedRatio

```
public void setHalfExpandedRatio(float ratio)
```

Determines the height of the BottomSheet in the `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_HALF_EXPANDED()` state. The material guidelines recommended a value of 0.5, which results in the sheet filling half of the parent. The height of the BottomSheet will be smaller as this ratio is decreased and taller as it is increased. The default value is 0.5.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_halfExpandedRatio

| Parameters |
|---|---|
| `float ratio` | a float between 0 and 1, representing the `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_HALF_EXPANDED()` ratio. |

### setHideFriction

```
public void setHideFriction(float hideFriction)
```

Sets the friction coefficient to hide the bottom sheet, or set it to the next closest expanded state.

| Parameters |
|---|---|
| `float hideFriction` | The friction coefficient that determines the swipe velocity needed to hide or set the bottom sheet to the closest expanded state. |

### setHideable

```
public void setHideable(boolean hideable)
```

Sets whether this bottom sheet can hide.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_hideable

| Parameters |
|---|---|
| `boolean hideable` | `true` to make this bottom sheet hideable. |

### setMaxHeight

```
public void setMaxHeight(int maxHeight)
```

Sets the maximum height of the bottom sheet. This method should be called before show in order for the height to be adjusted as expected.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_android_maxHeight

| Parameters |
|---|---|
| `int maxHeight` | The maximum height in pixels to be set |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getMaxHeight()` |   |

### setMaxWidth

```
public void setMaxWidth(int maxWidth)
```

Sets the maximum width of the bottom sheet. The layout will be at most this dimension wide. This method should be called before show in order for the width to be adjusted as expected.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_android_maxWidth

| Parameters |
|---|---|
| `int maxWidth` | The maximum width in pixels to be set |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getMaxWidth()` |   |

### setPeekHeight

```
public void setPeekHeight(int peekHeight)
```

Sets the height of the bottom sheet when it is collapsed.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_peekHeight

| Parameters |
|---|---|
| `int peekHeight` | The height of the collapsed bottom sheet in pixels, or `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#PEEK_HEIGHT_AUTO()` to configure the sheet to peek automatically at 16:9 ratio keyline. |

### setPeekHeight

```
public final void setPeekHeight(int peekHeight, boolean animate)
```

Sets the height of the bottom sheet when it is collapsed while optionally animating between the old height and the new height.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_peekHeight

| Parameters |
|---|---|
| `int peekHeight` | The height of the collapsed bottom sheet in pixels, or `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#PEEK_HEIGHT_AUTO()` to configure the sheet to peek automatically at 16:9 ratio keyline. |
| `boolean animate` | Whether to animate between the old height and the new height. |

### setSaveFlags

```
public void setSaveFlags(int flags)
```

Sets save flags to be preserved in bottomsheet on configuration change.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_saveFlags

| Parameters |
|---|---|
| `int flags` | bitwise int of `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_PEEK_HEIGHT()`, `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_FIT_TO_CONTENTS()`, `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_HIDEABLE()`, `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_SKIP_COLLAPSED()`, `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_ALL()` and `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#SAVE_NONE()`. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getSaveFlags()` |   |

### setShouldRemoveExpandedCorners

```
public void setShouldRemoveExpandedCorners(boolean shouldRemoveExpandedCorners)
```

Sets whether the bottom sheet should remove its corners when it reaches the expanded state.

If false, the bottom sheet will only remove its corners if it is expanded and reaches the top of the screen.

### setSignificantVelocityThreshold

```
public void setSignificantVelocityThreshold(int significantVelocityThreshold)
```

Sets the velocity threshold considered significant enough to trigger a slide to the next stable state.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_significantVelocityThreshold

| Parameters |
|---|---|
| `int significantVelocityThreshold` | The velocity threshold that warrants a vertical swipe. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#getSignificantVelocityThreshold()` |   |

### setSkipCollapsed

```
public void setSkipCollapsed(boolean skipCollapsed)
```

Sets whether this bottom sheet should skip the collapsed state when it is being hidden after it is expanded once. Setting this to true has no effect unless the sheet is hideable.

ref com.google.android.material.R.styleable#BottomSheetBehavior_Layout_behavior_skipCollapsed

| Parameters |
|---|---|
| `boolean skipCollapsed` | True if the bottom sheet should skip the collapsed state. |

### setState

```
public void setState(int state)
```

Sets the state of the bottom sheet. The bottom sheet will transition to that state with animation.

| Parameters |
|---|---|
| `int state` | One of `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_COLLAPSED()`, `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_EXPANDED()`, `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_HIDDEN()`, or `https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetBehavior#STATE_HALF_EXPANDED()`. |

### setUpdateImportantForAccessibilityOnSiblings

```
public void setUpdateImportantForAccessibilityOnSiblings(
    boolean updateImportantForAccessibilityOnSiblings
)
```

Sets whether the BottomSheet should update the accessibility status of its CoordinatorLayout siblings when expanded.

Set this to true if the expanded state of the sheet blocks access to siblings (e.g., when the sheet expands over the full screen).

### startBackProgress

```
public void startBackProgress(BackEventCompat backEvent)
```

Call this method from onBackStarted or handleOnBackStarted so that the back handler can initialize and start animating.

Note that this must be called prior to calling `https://developer.android.com/reference/com/google/android/material/motion/MaterialBackHandler#updateBackProgress(BackEventCompat)`.

### updateBackProgress

```
public void updateBackProgress(BackEventCompat backEvent)
```

Call this method from onBackProgressed or handleOnBackProgressed so that the back handler can continue animating with a new progress value.