Behavior
Interaction behavior plugin for child views of CoordinatorLayout.
A Behavior implements one or more interactions that a user can take on a child view. These interactions may include drags, swipes, flings, or any other gestures.
Parameters
<V>
The View type that this Behavior operates on
Inheritors
Constructors
Functions
Link copied to clipboard
open fun blocksInteractionBelow(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V): Boolean
Determine whether interaction with views behind the given child in the child order should be blocked.
Link copied to clipboard
open fun getInsetDodgeRect(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull rect: @NonNull Rect): Boolean
Called when a view is set to dodge view insets.
Link copied to clipboard
open fun getScrimColor(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V): Int
Supply a scrim color that will be painted behind the associated child view.
Link copied to clipboard
open fun getScrimOpacity(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V): Float
Determine the current opacity of the scrim behind a given child view A scrim may be used to indicate that the other elements beneath it are not currently interactive or actionable, drawing user focus and attention to the views above the scrim.
Link copied to clipboard
open fun layoutDependsOn(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull dependency: @NonNull View): Boolean
Determine whether the supplied child view has another specific sibling view as a layout dependency.
Link copied to clipboard
@NonNull
Called when the window insets have changed.
Link copied to clipboard
Called when the Behavior has been attached to a LayoutParams instance.
Link copied to clipboard
open fun onDependentViewChanged(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull dependency: @NonNull View): Boolean
Respond to a change in a child's dependent view This method is called whenever a dependent view changes in size or position outside of the standard layout flow.
Link copied to clipboard
open fun onDependentViewRemoved(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull dependency: @NonNull View)
Respond to a child's dependent view being removed.
Link copied to clipboard
Called when the Behavior has been detached from its holding LayoutParams instance.
Link copied to clipboard
open fun onInterceptTouchEvent(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull ev: @NonNull MotionEvent): Boolean
Respond to CoordinatorLayout touch events before they are dispatched to child views.
Link copied to clipboard
open fun onLayoutChild(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, layoutDirection: Int): Boolean
Called when the parent CoordinatorLayout is about the lay out the given child view.
Link copied to clipboard
open fun onMeasureChild(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, parentWidthMeasureSpec: Int, widthUsed: Int, parentHeightMeasureSpec: Int, heightUsed: Int): Boolean
Called when the parent CoordinatorLayout is about to measure the given child view.
Link copied to clipboard
open fun onNestedFling(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull target: @NonNull View, velocityX: Float, velocityY: Float, consumed: Boolean): Boolean
Called when a nested scrolling child is starting a fling or an action that would be a fling.
Link copied to clipboard
open fun onNestedPreFling(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull target: @NonNull View, velocityX: Float, velocityY: Float): Boolean
Called when a nested scrolling child is about to start a fling.
Link copied to clipboard
open fun onNestedPreScroll(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull target: @NonNull View, dx: Int, dy: Int, consumed: @NonNull Array<Int>)
open fun onNestedPreScroll(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull target: @NonNull View, dx: Int, dy: Int, consumed: @NonNull Array<Int>, type: Int)
Called when a nested scroll in progress is about to update, before the target has consumed any of the scrolled distance.
Link copied to clipboard
open fun onNestedScroll(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull target: @NonNull View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int)
open fun onNestedScroll(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull target: @NonNull View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, type: Int)
open fun onNestedScroll(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull target: @NonNull View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, type: Int, consumed: @NonNull Array<Int>)
Called when a nested scroll in progress has updated and the target has scrolled or attempted to scroll.
Link copied to clipboard
open fun onNestedScrollAccepted(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull directTargetChild: @NonNull View, @NonNull target: @NonNull View, axes: Int)
open fun onNestedScrollAccepted(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull directTargetChild: @NonNull View, @NonNull target: @NonNull View, axes: Int, type: Int)
Called when a nested scroll has been accepted by the CoordinatorLayout.
Link copied to clipboard
open fun onRequestChildRectangleOnScreen(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull rectangle: @NonNull Rect, immediate: Boolean): Boolean
Called when a child of the view associated with this behavior wants a particular rectangle to be positioned onto the screen.
Link copied to clipboard
open fun onRestoreInstanceState(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull state: @NonNull Parcelable)
Hook allowing a behavior to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState.
Link copied to clipboard
@Nullable
Hook allowing a behavior to generate a representation of its internal state that can later be used to create a new instance with that same state.
Link copied to clipboard
open fun onStartNestedScroll(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull directTargetChild: @NonNull View, @NonNull target: @NonNull View, axes: Int): Boolean
open fun onStartNestedScroll(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull directTargetChild: @NonNull View, @NonNull target: @NonNull View, axes: Int, type: Int): Boolean
Called when a descendant of the CoordinatorLayout attempts to initiate a nested scroll.
Link copied to clipboard
open fun onStopNestedScroll(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull target: @NonNull View)
open fun onStopNestedScroll(@NonNull coordinatorLayout: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull target: @NonNull View, type: Int)
Called when a nested scroll has ended.
Link copied to clipboard
open fun onTouchEvent(@NonNull parent: @NonNull CoordinatorLayout, @NonNull child: @NonNull V, @NonNull ev: @NonNull MotionEvent): Boolean
Respond to CoordinatorLayout touch events after this Behavior has started intercepting them.