BottomSheetBehavior
public
class
BottomSheetBehavior
extends Behavior<V extends View>
java.lang.Object | ||
↳ | androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior<V extends android.view.View> | |
↳ | com.google.android.material.bottomsheet.BottomSheetBehavior<V extends android.view.View> |
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 AppCompatDialog.setTitle(int)
, and for
BottomSheetDialogFragment use ViewCompat.setAccessibilityPaneTitle(View, CharSequence)
.
For more information, see the component developer guidance and design guidelines.
Summary
Nested classes | |
---|---|
class |
BottomSheetBehavior.BottomSheetCallback
Callback for monitoring events about bottom sheets. |
class |
BottomSheetBehavior.SavedState
State persisted across instances |
XML attributes | |
---|---|
BottomSheetBehavior_Layout_android_maxHeight |
|
BottomSheetBehavior_Layout_android_maxWidth |
|
BottomSheetBehavior_Layout_behavior_draggable |
|
BottomSheetBehavior_Layout_behavior_expandedOffset |
|
BottomSheetBehavior_Layout_behavior_halfExpandedRatio |
|
BottomSheetBehavior_Layout_behavior_hideable |
|
BottomSheetBehavior_Layout_behavior_peekHeight |
|
BottomSheetBehavior_Layout_behavior_saveFlags |
|
BottomSheetBehavior_Layout_behavior_skipCollapsed |
Constants | |
---|---|
int |
PEEK_HEIGHT_AUTO
Peek at the 16:9 ratio keyline of its parent. |
int |
SAVE_ALL
This flag will preserve all aforementioned values on configuration change. |
int |
SAVE_FIT_TO_CONTENTS
This flag will preserve the fitToContents boolean value on configuration change. |
int |
SAVE_HIDEABLE
This flag will preserve the hideable boolean value on configuration change. |
int |
SAVE_NONE
This flag will not preserve the aforementioned values set at runtime if the view is destroyed and recreated. |
int |
SAVE_PEEK_HEIGHT
This flag will preserve the peekHeight int value on configuration change. |
int |
SAVE_SKIP_COLLAPSED
This flag will preserve the skipCollapsed boolean value on configuration change. |
int |
STATE_COLLAPSED
The bottom sheet is collapsed. |
int |
STATE_DRAGGING
The bottom sheet is dragging. |
int |
STATE_EXPANDED
The bottom sheet is expanded. |
int |
STATE_HALF_EXPANDED
The bottom sheet is half-expanded (used when fitToContents is false). |
int |
STATE_HIDDEN
The bottom sheet is hidden. |
int |
STATE_SETTLING
The bottom sheet is settling. |
Public constructors | |
---|---|
BottomSheetBehavior()
|
|
BottomSheetBehavior(Context context, AttributeSet attrs)
|
Public methods | |
---|---|
void
|
addBottomSheetCallback(BottomSheetBehavior.BottomSheetCallback callback)
Adds a callback to be notified of bottom sheet events. |
float
|
calculateSlideOffset()
Calculates the current offset of the bottom sheet. |
void
|
cancelBackProgress()
|
static
<V extends View>
BottomSheetBehavior<V>
|
from(V view)
A utility function to get the |
int
|
getExpandedOffset()
Returns the current expanded offset. |
float
|
getHalfExpandedRatio()
Gets the ratio for the height of the BottomSheet in the |
float
|
getHideFriction()
Gets the friction coefficient to hide the bottom sheet, or set it to the next closest expanded state. |
int
|
getMaxHeight()
Returns the bottom sheet's maximum height, or -1 if no maximum height is set. |
int
|
getMaxWidth()
Returns the bottom sheet's maximum width, or -1 if no maximum width is set. |
int
|
getPeekHeight()
Gets the height of the bottom sheet when it is collapsed. |
int
|
getSaveFlags()
Returns the save flags. |
int
|
getSignificantVelocityThreshold()
|
boolean
|
getSkipCollapsed()
Sets whether this bottom sheet should skip the collapsed state when it is being hidden after it is expanded once. |
int
|
getState()
Gets the current state of the bottom sheet. |
void
|
handleBackInvoked()
|
boolean
|
isDraggable()
|
boolean
|
isFitToContents()
|
boolean
|
isGestureInsetBottomIgnored()
Returns whether this bottom sheet should adjust it's position based on the system gesture area. |
boolean
|
isHideable()
Gets whether this bottom sheet can hide when it is swiped down. |
boolean
|
isShouldRemoveExpandedCorners()
Returns whether the bottom sheet will remove its corners when it reaches the expanded state. |
void
|
onAttachedToLayoutParams(CoordinatorLayout.LayoutParams layoutParams)
|
void
|
onDetachedFromLayoutParams()
|
boolean
|
onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event)
|
boolean
|
onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection)
|
boolean
|
onMeasureChild(CoordinatorLayout parent, V child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)
|
boolean
|
onNestedPreFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY)
|
void
|
onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, int type)
|
void
|
onNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, int[] consumed)
|
void
|
onRestoreInstanceState(CoordinatorLayout parent, V child, Parcelable state)
|
Parcelable
|
onSaveInstanceState(CoordinatorLayout parent, V child)
|
boolean
|
onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int axes, int type)
|
void
|
onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target, int type)
|
boolean
|
onTouchEvent(CoordinatorLayout parent, V child, MotionEvent event)
|
void
|
removeBottomSheetCallback(BottomSheetBehavior.BottomSheetCallback callback)
Removes a previously added callback. |
void
|
setBottomSheetCallback(BottomSheetBehavior.BottomSheetCallback callback)
This method is deprecated.
use |
void
|
setDraggable(boolean draggable)
Sets whether this bottom sheet is can be collapsed/expanded by dragging. |
void
|
setExpandedOffset(int offset)
Determines the top offset of the BottomSheet in the |
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). |
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. |
void
|
setHalfExpandedRatio(float ratio)
Determines the height of the BottomSheet in the |
void
|
setHideFriction(float hideFriction)
Sets the friction coefficient to hide the bottom sheet, or set it to the next closest expanded state. |
void
|
setHideable(boolean hideable)
Sets whether this bottom sheet can hide. |
void
|
setMaxHeight(int maxHeight)
Sets the maximum height of the bottom sheet. |
void
|
setMaxWidth(int maxWidth)
Sets the maximum width of the bottom sheet. |
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. |
void
|
setPeekHeight(int peekHeight)
Sets the height of the bottom sheet when it is collapsed. |
void
|
setSaveFlags(int flags)
Sets save flags to be preserved in bottomsheet on configuration change. |
void
|
setShouldRemoveExpandedCorners(boolean shouldRemoveExpandedCorners)
Sets whether the bottom sheet should remove its corners when it reaches the expanded state. |
void
|
setSignificantVelocityThreshold(int significantVelocityThreshold)
|
void
|
setSkipCollapsed(boolean skipCollapsed)
Sets whether this bottom sheet should skip the collapsed state when it is being hidden after it is expanded once. |
void
|
setState(int state)
Sets the state of the bottom sheet. |
void
|
setUpdateImportantForAccessibilityOnSiblings(boolean updateImportantForAccessibilityOnSiblings)
Sets whether the BottomSheet should update the accessibility status of its |
void
|
startBackProgress(BackEventCompat backEvent)
|
void
|
updateBackProgress(BackEventCompat backEvent)
|
Inherited methods | |
---|---|
XML attributes
BottomSheetBehavior_Layout_android_maxHeight
Related methods:
BottomSheetBehavior_Layout_android_maxWidth
Related methods:
BottomSheetBehavior_Layout_behavior_draggable
Related methods:
BottomSheetBehavior_Layout_behavior_expandedOffset
Related methods:
BottomSheetBehavior_Layout_behavior_halfExpandedRatio
Related methods:
BottomSheetBehavior_Layout_behavior_hideable
Related methods:
BottomSheetBehavior_Layout_behavior_peekHeight
Related methods:
BottomSheetBehavior_Layout_behavior_saveFlags
Related methods:
BottomSheetBehavior_Layout_behavior_skipCollapsed
Related methods:
Constants
PEEK_HEIGHT_AUTO
public static final int PEEK_HEIGHT_AUTO
Peek at the 16:9 ratio keyline of its parent.
This can be used as a parameter for setPeekHeight(int)
. getPeekHeight()
will return this when the value is set.
Constant Value: -1 (0xffffffff)
SAVE_ALL
public static final int SAVE_ALL
This flag will preserve all aforementioned values on configuration change.
Constant Value: -1 (0xffffffff)
SAVE_FIT_TO_CONTENTS
public static final int SAVE_FIT_TO_CONTENTS
This flag will preserve the fitToContents boolean value on configuration change.
Constant Value: 2 (0x00000002)
SAVE_HIDEABLE
public static final int SAVE_HIDEABLE
This flag will preserve the hideable boolean value on configuration change.
Constant Value: 4 (0x00000004)
SAVE_NONE
public static final int SAVE_NONE
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.
Constant Value: 0 (0x00000000)
SAVE_PEEK_HEIGHT
public static final int SAVE_PEEK_HEIGHT
This flag will preserve the peekHeight int value on configuration change.
Constant Value: 1 (0x00000001)
SAVE_SKIP_COLLAPSED
public static final int SAVE_SKIP_COLLAPSED
This flag will preserve the skipCollapsed boolean value on configuration change.
Constant Value: 8 (0x00000008)
STATE_COLLAPSED
public static final int STATE_COLLAPSED
The bottom sheet is collapsed.
Constant Value: 4 (0x00000004)
STATE_DRAGGING
public static final int STATE_DRAGGING
The bottom sheet is dragging.
Constant Value: 1 (0x00000001)
STATE_EXPANDED
public static final int STATE_EXPANDED
The bottom sheet is expanded.
Constant Value: 3 (0x00000003)
STATE_HALF_EXPANDED
public static final int STATE_HALF_EXPANDED
The bottom sheet is half-expanded (used when fitToContents is false).
Constant Value: 6 (0x00000006)
STATE_HIDDEN
public static final int STATE_HIDDEN
The bottom sheet is hidden.
Constant Value: 5 (0x00000005)
STATE_SETTLING
public static final int STATE_SETTLING
The bottom sheet is settling.
Constant Value: 2 (0x00000002)
Public constructors
BottomSheetBehavior
public BottomSheetBehavior ()
BottomSheetBehavior
public BottomSheetBehavior (Context context, AttributeSet attrs)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
Public methods
addBottomSheetCallback
public void addBottomSheetCallback (BottomSheetBehavior.BottomSheetCallback callback)
Adds a callback to be notified of bottom sheet events.
Parameters | |
---|---|
callback |
BottomSheetBehavior.BottomSheetCallback : 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 ()
from
public static BottomSheetBehavior<V> from (V view)
A utility function to get the BottomSheetBehavior
associated with the view
.
Parameters | |
---|---|
view |
V : The View with BottomSheetBehavior . |
Returns | |
---|---|
BottomSheetBehavior<V> |
The BottomSheetBehavior associated with the view .
|
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.
Related XML Attributes:
Returns | |
---|---|
int |
getHalfExpandedRatio
public float getHalfExpandedRatio ()
Gets the ratio for the height of the BottomSheet in the STATE_HALF_EXPANDED
state.
Related XML Attributes:
Returns | |
---|---|
float |
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.
Related XML Attributes:
Returns | |
---|---|
int |
See also:
getMaxWidth
public int getMaxWidth ()
Returns the bottom sheet's maximum width, or -1 if no maximum width is set.
Related XML Attributes:
Returns | |
---|---|
int |
See also:
getPeekHeight
public int getPeekHeight ()
Gets the height of the bottom sheet when it is collapsed.
Related XML Attributes:
Returns | |
---|---|
int |
The height of the collapsed bottom sheet in pixels, or PEEK_HEIGHT_AUTO if the
sheet is configured to peek automatically at 16:9 ratio keyline |
getSaveFlags
public int getSaveFlags ()
Returns the save flags.
Related XML Attributes:
Returns | |
---|---|
int |
See also:
getSignificantVelocityThreshold
public int getSignificantVelocityThreshold ()
Returns | |
---|---|
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.
Related XML Attributes:
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 STATE_EXPANDED , STATE_HALF_EXPANDED , STATE_COLLAPSED ,
STATE_DRAGGING , or STATE_SETTLING .
|
handleBackInvoked
public void handleBackInvoked ()
isDraggable
public boolean isDraggable ()
Returns | |
---|---|
boolean |
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.
Returns | |
---|---|
boolean |
isHideable
public boolean isHideable ()
Gets whether this bottom sheet can hide when it is swiped down.
Related XML Attributes:
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.
Returns | |
---|---|
boolean |
onAttachedToLayoutParams
public void onAttachedToLayoutParams (CoordinatorLayout.LayoutParams layoutParams)
Parameters | |
---|---|
layoutParams |
CoordinatorLayout.LayoutParams |
onDetachedFromLayoutParams
public void onDetachedFromLayoutParams ()
onInterceptTouchEvent
public boolean onInterceptTouchEvent (CoordinatorLayout parent, V child, MotionEvent event)
Parameters | |
---|---|
parent |
CoordinatorLayout |
child |
V |
event |
MotionEvent |
Returns | |
---|---|
boolean |
onLayoutChild
public boolean onLayoutChild (CoordinatorLayout parent, V child, int layoutDirection)
Parameters | |
---|---|
parent |
CoordinatorLayout |
child |
V |
layoutDirection |
int |
Returns | |
---|---|
boolean |
onMeasureChild
public boolean onMeasureChild (CoordinatorLayout parent, V child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)
Parameters | |
---|---|
parent |
CoordinatorLayout |
child |
V |
parentWidthMeasureSpec |
int |
widthUsed |
int |
parentHeightMeasureSpec |
int |
heightUsed |
int |
Returns | |
---|---|
boolean |
onNestedPreFling
public boolean onNestedPreFling (CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY)
Parameters | |
---|---|
coordinatorLayout |
CoordinatorLayout |
child |
V |
target |
View |
velocityX |
float |
velocityY |
float |
Returns | |
---|---|
boolean |
onNestedPreScroll
public void onNestedPreScroll (CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed, int type)
Parameters | |
---|---|
coordinatorLayout |
CoordinatorLayout |
child |
V |
target |
View |
dx |
int |
dy |
int |
consumed |
int |
type |
int |
onNestedScroll
public void onNestedScroll (CoordinatorLayout coordinatorLayout, V child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, int[] consumed)
Parameters | |
---|---|
coordinatorLayout |
CoordinatorLayout |
child |
V |
target |
View |
dxConsumed |
int |
dyConsumed |
int |
dxUnconsumed |
int |
dyUnconsumed |
int |
type |
int |
consumed |
int |
onRestoreInstanceState
public void onRestoreInstanceState (CoordinatorLayout parent, V child, Parcelable state)
Parameters | |
---|---|
parent |
CoordinatorLayout |
child |
V |
state |
Parcelable |
onSaveInstanceState
public Parcelable onSaveInstanceState (CoordinatorLayout parent, V child)
Parameters | |
---|---|
parent |
CoordinatorLayout |
child |
V |
Returns | |
---|---|
Parcelable |
onStartNestedScroll
public boolean onStartNestedScroll (CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int axes, int type)
Parameters | |
---|---|
coordinatorLayout |
CoordinatorLayout |
child |
V |
directTargetChild |
View |
target |
View |
axes |
int |
type |
int |
Returns | |
---|---|
boolean |
onStopNestedScroll
public void onStopNestedScroll (CoordinatorLayout coordinatorLayout, V child, View target, int type)
Parameters | |
---|---|
coordinatorLayout |
CoordinatorLayout |
child |
V |
target |
View |
type |
int |
onTouchEvent
public boolean onTouchEvent (CoordinatorLayout parent, V child, MotionEvent event)
Parameters | |
---|---|
parent |
CoordinatorLayout |
child |
V |
event |
MotionEvent |
Returns | |
---|---|
boolean |
removeBottomSheetCallback
public void removeBottomSheetCallback (BottomSheetBehavior.BottomSheetCallback callback)
Removes a previously added callback.
Parameters | |
---|---|
callback |
BottomSheetBehavior.BottomSheetCallback : The callback to remove.
|
setBottomSheetCallback
public void setBottomSheetCallback (BottomSheetBehavior.BottomSheetCallback callback)
This method is deprecated.
use addBottomSheetCallback(BottomSheetCallback)
and removeBottomSheetCallback(BottomSheetCallback)
instead
Sets a callback to be notified of bottom sheet events.
Parameters | |
---|---|
callback |
BottomSheetBehavior.BottomSheetCallback : The callback to notify when bottom sheet events occur. |
setDraggable
public void setDraggable (boolean draggable)
Sets whether this bottom sheet is 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
Related XML Attributes:
Parameters | |
---|---|
draggable |
boolean : false to prevent dragging the sheet to collapse and expand |
setExpandedOffset
public void setExpandedOffset (int offset)
Determines the top offset of the BottomSheet in the STATE_EXPANDED
state when
fitsToContent is false. The default value is 0, which results in the sheet matching the
parent's top.
Related XML Attributes:
Parameters | |
---|---|
offset |
int : an integer value greater than equal to 0, representing the 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 | |
---|---|
fitToContents |
boolean : 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.
Parameters | |
---|---|
gestureInsetBottomIgnored |
boolean |
setHalfExpandedRatio
public void setHalfExpandedRatio (float ratio)
Determines the height of the BottomSheet in the 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.
Related XML Attributes:
Parameters | |
---|---|
ratio |
float : a float between 0 and 1, representing the 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 | |
---|---|
hideFriction |
float : 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.
Related XML Attributes:
Parameters | |
---|---|
hideable |
boolean : 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 Dialog.show()
in order for the height to be adjusted as expected.
Related XML Attributes:
Parameters | |
---|---|
maxHeight |
int : The maximum height in pixels to be set |
See also:
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 Dialog.show()
in order for the width to
be adjusted as expected.
Related XML Attributes:
Parameters | |
---|---|
maxWidth |
int : The maximum width in pixels to be set |
See also:
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.
Related XML Attributes:
Parameters | |
---|---|
peekHeight |
int : The height of the collapsed bottom sheet in pixels, or PEEK_HEIGHT_AUTO to configure the sheet to peek automatically at 16:9 ratio keyline. |
animate |
boolean : Whether to animate between the old height and the new height. |
setPeekHeight
public void setPeekHeight (int peekHeight)
Sets the height of the bottom sheet when it is collapsed.
Related XML Attributes:
Parameters | |
---|---|
peekHeight |
int : The height of the collapsed bottom sheet in pixels, or PEEK_HEIGHT_AUTO to configure the sheet to peek automatically at 16:9 ratio keyline. |
setSaveFlags
public void setSaveFlags (int flags)
Sets save flags to be preserved in bottomsheet on configuration change.
Related XML Attributes:
Parameters | |
---|---|
flags |
int : bitwise int of SAVE_PEEK_HEIGHT , SAVE_FIT_TO_CONTENTS , SAVE_HIDEABLE , SAVE_SKIP_COLLAPSED , SAVE_ALL and SAVE_NONE . |
See also:
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.
Parameters | |
---|---|
shouldRemoveExpandedCorners |
boolean |
setSignificantVelocityThreshold
public void setSignificantVelocityThreshold (int significantVelocityThreshold)
Parameters | |
---|---|
significantVelocityThreshold |
int |
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.
Related XML Attributes:
Parameters | |
---|---|
skipCollapsed |
boolean : 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 | |
---|---|
state |
int : One of STATE_COLLAPSED , STATE_EXPANDED , STATE_HIDDEN ,
or 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).
Parameters | |
---|---|
updateImportantForAccessibilityOnSiblings |
boolean |
startBackProgress
public void startBackProgress (BackEventCompat backEvent)
Parameters | |
---|---|
backEvent |
BackEventCompat |
updateBackProgress
public void updateBackProgress (BackEventCompat backEvent)
Parameters | |
---|---|
backEvent |
BackEventCompat |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2023-12-15 UTC.