BottomSheetBehavior

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 and design guidelines.

Constructors

Link copied to clipboard
constructor()
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet)

Types

Link copied to clipboard
abstract class BottomSheetCallback
Callback for monitoring events about bottom sheets.
Link copied to clipboard
Link copied to clipboard
Stable states that can be set by the setState method.
Link copied to clipboard

Properties

Link copied to clipboard
Link copied to clipboard
@get:FloatRange(from = 0.0, to = 1.0)
open var halfExpandedRatio: Float
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@get:Px
open var maxHeight: Int
Link copied to clipboard
@get:Px
open var maxWidth: Int
Link copied to clipboard
Peek at the 16:9 ratio keyline of its parent.
Link copied to clipboard
open var peekHeight: Int
Peek height set by the user.
Link copied to clipboard
val SAVE_ALL: Int = -1
This flag will preserve all aforementioned values on configuration change.
Link copied to clipboard
This flag will preserve the fitToContents boolean value on configuration change.
Link copied to clipboard
This flag will preserve the hideable boolean value on configuration change.
Link copied to clipboard
val SAVE_NONE: Int = 0
This flag will not preserve the aforementioned values set at runtime if the view is destroyed and recreated.
Link copied to clipboard
This flag will preserve the peekHeight int value on configuration change.
Link copied to clipboard
This flag will preserve the skipCollapsed boolean value on configuration change.
Link copied to clipboard
open var saveFlags: Int
Link copied to clipboard
Link copied to clipboard
open var state: Int
Link copied to clipboard
The bottom sheet is collapsed.
Link copied to clipboard
The bottom sheet is dragging.
Link copied to clipboard
The bottom sheet is expanded.
Link copied to clipboard
The bottom sheet is half-expanded (used when fitToContents is false).
Link copied to clipboard
val STATE_HIDDEN: Int = 5
The bottom sheet is hidden.
Link copied to clipboard
The bottom sheet is settling.

Functions

Link copied to clipboard
Adds a callback to be notified of bottom sheet events.
Link copied to clipboard
Calculates the current offset of the bottom sheet.
Link copied to clipboard
Call this method from onBackCancelled or handleOnBackCancelled so that the back handler can cancel the back animation.
Link copied to clipboard
Disables the shaped corner ShapeAppearanceModel interpolation transition animations.
Link copied to clipboard
open fun <V : View?> from(@NonNull view: V): BottomSheetBehavior<V>
A utility function to get the BottomSheetBehavior associated with the view.
Link copied to clipboard
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.
Link copied to clipboard
open fun isDraggable(): Boolean
Link copied to clipboard
Link copied to clipboard
Returns whether this bottom sheet should adjust it's position based on the system gesture area.
Link copied to clipboard
open fun isHideable(): Boolean
Gets whether this bottom sheet can hide when it is swiped down.
Link copied to clipboard
Checks whether hiding gestures should be enabled while isHideable is set to true.
Link copied to clipboard
Checks weather a nested scroll should be enabled.
Link copied to clipboard
Returns whether the bottom sheet will remove its corners when it reaches the expanded state.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun onLayoutChild(@NonNull parent: CoordinatorLayout, @NonNull child: V, layoutDirection: Int): Boolean
Link copied to clipboard
open fun onMeasureChild(@NonNull parent: CoordinatorLayout, @NonNull child: V, parentWidthMeasureSpec: Int, widthUsed: Int, parentHeightMeasureSpec: Int, heightUsed: Int): Boolean
Link copied to clipboard
open fun onNestedPreFling(@NonNull coordinatorLayout: CoordinatorLayout, @NonNull child: V, @NonNull target: View, velocityX: Float, velocityY: Float): Boolean
Link copied to clipboard
open fun onNestedPreScroll(@NonNull coordinatorLayout: CoordinatorLayout, @NonNull child: V, @NonNull target: View, dx: Int, dy: Int, @NonNull consumed: Array<Int>, type: Int)
Link copied to clipboard
open fun onNestedScroll(@NonNull coordinatorLayout: CoordinatorLayout, @NonNull child: V, @NonNull target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, type: Int, @NonNull consumed: Array<Int>)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun onStartNestedScroll(@NonNull coordinatorLayout: CoordinatorLayout, @NonNull child: V, @NonNull directTargetChild: View, @NonNull target: View, axes: Int, type: Int): Boolean
Link copied to clipboard
open fun onStopNestedScroll(@NonNull coordinatorLayout: CoordinatorLayout, @NonNull child: V, @NonNull target: View, type: Int)
Link copied to clipboard
open fun onTouchEvent(@NonNull parent: CoordinatorLayout, @NonNull child: V, @NonNull event: MotionEvent): Boolean
Link copied to clipboard
Removes a previously added callback.
Link copied to clipboard
Sets a callback to be notified of bottom sheet events.
Link copied to clipboard
open fun setDraggable(draggable: Boolean)
Sets whether this bottom sheet is can be collapsed/expanded by dragging.
Link copied to clipboard
open fun setFitToContents(fitToContents: Boolean)
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).
Link copied to clipboard
open fun setGestureInsetBottomIgnored(gestureInsetBottomIgnored: Boolean)
Sets whether this bottom sheet should adjust it's position based on the system gesture area on Android Q and above.
Link copied to clipboard
open fun setHideable(hideable: Boolean)
Sets whether this bottom sheet can hide.
Link copied to clipboard
Sets whether this bottom sheet can hide when it is swiped down.
Link copied to clipboard
fun setPeekHeight(peekHeight: Int, animate: Boolean)
Sets the height of the bottom sheet when it is collapsed while optionally animating between the old height and the new height.
Link copied to clipboard
open fun setShouldRemoveExpandedCorners(shouldRemoveExpandedCorners: Boolean)
Sets whether the bottom sheet should remove its corners when it reaches the expanded state.
open fun setUpdateImportantForAccessibilityOnSiblings(updateImportantForAccessibilityOnSiblings: Boolean)
Sets whether the BottomSheet should update the accessibility status of its siblings when expanded.
Link copied to clipboard
open fun shouldExpandOnUpwardDrag(dragDurationMillis: Long, @FloatRange(from = 0.0, to = 100.0) yPositionPercentage: Float): Boolean
Checks whether the bottom sheet should be expanded after it has been released after dragging.
Link copied to clipboard
Checks weather half expended state should be skipped when drag is ended.
Link copied to clipboard
Checks whether an animation should be smooth after the bottomSheet is released after dragging.
Link copied to clipboard
Call this method from onBackStarted or handleOnBackStarted so that the back handler can initialize and start animating.
Link copied to clipboard
Call this method from onBackProgressed or handleOnBackProgressed so that the back handler can continue animating with a new progress value.