# SideSheetBehavior

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

*** ** * ** ***


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

<br />

*** ** * ** ***

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

For more information, see the [component developer guidance](https://github.com/material-components/material-components-android/blob/master/docs/components/SideSheet.md) and [design guidelines](https://material.io/components/side-sheets/overview).

## Summary

| ### Nested types |
|---|
| `protected class https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior.SavedState` State persisted across instances |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#EDGE_LEFT() = 1` The sheet is based on the left edge of the screen; it slides from the left edge towards the right. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#EDGE_RIGHT() = 0` The sheet is based on the right edge of the screen; it slides from the right edge towards the left. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#STATE_DRAGGING() = 1` The sheet is dragging. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#STATE_EXPANDED() = 3` The sheet is expanded. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#STATE_HIDDEN() = 5` The sheet is hidden. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#STATE_SETTLING() = 2` The sheet is settling. |

| ### Public fields |
|---|---|
| `float` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#hideFriction()` |
| `int` | `@https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet.SheetState https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#state()` |

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

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#addCallback(com.google.android.material.sidesheet.SideSheetCallback)(https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetCallback callback)` Adds a callback to be notified of side sheet events. |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#cancelBackProgress()()` Call this method from onBackCancelled or handleOnBackCancelled so that the back handler can cancel the back animation. |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#expand()()` Expand the sheet by setting the side sheet state to `https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet#STATE_EXPANDED()`. |
| `static https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior<V>` | `<V extends View> https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#from(V)(V view)` A utility function to get the `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior` associated with the `view`. |
| `View` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#getCoplanarSiblingView()()` Returns the sibling view that is used for coplanar sheet expansion. |
| `int` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#getExpandedOffset()()` Returns the sheet's offset from the inner edge when expanded. |
| `float` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#getHideFriction()()` Gets the friction coefficient to hide the sheet, or set it to the next closest expanded state. |
| `int` | `@https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet.SheetState https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#getState()()` Gets the current state of the sheet. |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#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. |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#hide()()` Hide the sheet by setting the sheet state to `https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet#STATE_HIDDEN()`. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#isDraggable()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#onAttachedToLayoutParams(LayoutParams)(LayoutParams layoutParams)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#onDetachedFromLayoutParams()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#onInterceptTouchEvent(CoordinatorLayout,V,MotionEvent)( CoordinatorLayout parent, V child, MotionEvent event )` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#onLayoutChild(CoordinatorLayout,V,int)(CoordinatorLayout parent, V child, int layoutDirection)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#onMeasureChild(CoordinatorLayout,V,int,int,int,int)( CoordinatorLayout parent, V child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed )` |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#onRestoreInstanceState(CoordinatorLayout,V,Parcelable)( CoordinatorLayout parent, V child, Parcelable state )` |
| `Parcelable` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#onSaveInstanceState(CoordinatorLayout,V)(CoordinatorLayout parent, V child)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#onTouchEvent(CoordinatorLayout,V,MotionEvent)(CoordinatorLayout parent, V child, MotionEvent event)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#removeCallback(com.google.android.material.sidesheet.SideSheetCallback)(https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetCallback callback)` Removes a previously added callback. |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#setCoplanarSiblingView(View)(View coplanarSiblingView)` Set the sibling view to use for coplanar sheet expansion. |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#setCoplanarSiblingViewId(int)(int coplanarSiblingViewId)` Set the sibling id to use for coplanar sheet expansion. |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#setDraggable(boolean)(boolean draggable)` Sets whether this sheet is can be hidden/expanded by dragging. |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#setHideFriction(float)(float hideFriction)` Sets the friction coefficient to hide the sheet, or set it to the next closest expanded state. |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#setState(int)(int state)` Sets the state of the sheet. |
| `void` | `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#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/sidesheet/SideSheetBehavior#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

### EDGE_LEFT

```
public static final int EDGE_LEFT = 1
```

The sheet is based on the left edge of the screen; it slides from the left edge towards the right.

### EDGE_RIGHT

```
public static final int EDGE_RIGHT = 0
```

The sheet is based on the right edge of the screen; it slides from the right edge towards the left.

### STATE_DRAGGING

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

The sheet is dragging.

### STATE_EXPANDED

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

The sheet is expanded.

### STATE_HIDDEN

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

The sheet is hidden.

### STATE_SETTLING

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

The sheet is settling.

## Public fields

### hideFriction

```
public float hideFriction
```

### state

```
@Sheet.SheetState
public int state
```

## Public constructors

### SideSheetBehavior

```
public SideSheetBehavior()
```

### SideSheetBehavior

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

## Public methods

### addCallback

```
public void addCallback(SideSheetCallback callback)
```

Adds a callback to be notified of side sheet events.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetCallback callback` | The callback to notify when side sheet events occur. |

### cancelBackProgress

```
public void cancelBackProgress()
```

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

### expand

```
public void expand()
```

Expand the sheet by setting the side sheet state to `https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet#STATE_EXPANDED()`. This is a convenience method for `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#setState(int)`.

### from

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

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

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

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

### getCoplanarSiblingView

```
public View getCoplanarSiblingView()
```

Returns the sibling view that is used for coplanar sheet expansion.

### getExpandedOffset

```
public int getExpandedOffset()
```

Returns the sheet's offset from the inner edge when expanded. It will calculate the offset based on the width of the content.

### getHideFriction

```
public float getHideFriction()
```

Gets the friction coefficient to hide the 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 sheet to the closest expanded state. |

### getState

```
@Sheet.SheetState
public int getState()
```

Gets the current state of the sheet.

| Returns |
|---|---|
| `int` | One of `https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet#STATE_EXPANDED()`, `https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet#STATE_DRAGGING()`, `https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet#STATE_SETTLING()`, or `https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet#STATE_HIDDEN()`. |

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

### hide

```
public void hide()
```

Hide the sheet by setting the sheet state to `https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet#STATE_HIDDEN()`. This is a convenience method for `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#setState(int)`.

### isDraggable

```
public boolean isDraggable()
```

### 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
)
```

### onRestoreInstanceState

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

### onSaveInstanceState

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

### onTouchEvent

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

### removeCallback

```
public void removeCallback(SideSheetCallback callback)
```

Removes a previously added callback.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetCallback callback` | The callback to remove. |

### setCoplanarSiblingView

```
public void setCoplanarSiblingView(View coplanarSiblingView)
```

Set the sibling view to use for coplanar sheet expansion. If a coplanar sibling has previously been set either by this method or via `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#setCoplanarSiblingViewId(int)`, that reference will be cleared in favor of this new coplanar sibling reference.

| Parameters |
|---|---|
| `View coplanarSiblingView` | the sibling view to squash during coplanar expansion |

### setCoplanarSiblingViewId

```
public void setCoplanarSiblingViewId(int coplanarSiblingViewId)
```

Set the sibling id to use for coplanar sheet expansion. If a coplanar sibling has previously been set either by this method or via `https://developer.android.com/reference/com/google/android/material/sidesheet/SideSheetBehavior#setCoplanarSiblingView(View)`, that View reference will be cleared in favor of this new coplanar sibling reference.

| Parameters |
|---|---|
| `int coplanarSiblingViewId` | the id of the coplanar sibling |

### setDraggable

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

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

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

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

### setHideFriction

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

Sets the friction coefficient to hide the 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 sheet to the closest expanded state. |

### setState

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

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

| Parameters |
|---|---|
| `int state` | One of `https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet#STATE_EXPANDED()` or `https://developer.android.com/reference/com/google/android/material/sidesheet/Sheet#STATE_HIDDEN()`. |

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