Android 12 Developer Preview is here! Try it out, and give us your feedback!


abstract class Behavior<V : View!>
   ↳ androidx.coordinatorlayout.widget.CoordinatorLayout.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.


Public constructors

Default constructor for instantiating Behaviors.

<init>(context: Context!, attrs: AttributeSet!)

Default constructor for inflating Behaviors from layout.

Public methods
open Boolean
blocksInteractionBelow(@NonNull parent: CoordinatorLayout, @NonNull child: V)

Determine whether interaction with views behind the given child in the child order should be blocked.

open Boolean
getInsetDodgeRect(@NonNull parent: CoordinatorLayout, @NonNull child: V, @NonNull rect: Rect)

Called when a view is set to dodge view insets.

open Int
getScrimColor(@NonNull parent: CoordinatorLayout, @NonNull child: V)

Supply a scrim color that will be painted behind the associated child view.

open Float
getScrimOpacity(@NonNull parent: CoordinatorLayout, @NonNull child: V)

Determine the current opacity of the scrim behind a given child view

open static Any?
getTag(@NonNull child: View)

Get the behavior-specific tag object with the given child view.

open Boolean
layoutDependsOn(@NonNull parent: CoordinatorLayout, @NonNull child: V, @NonNull dependency: View)

Determine whether the supplied child view has another specific sibling view as a layout dependency.

open WindowInsetsCompat
onApplyWindowInsets(@NonNull coordinatorLayout: CoordinatorLayout, @NonNull child: V, @NonNull insets: WindowInsetsCompat)

Called when the window insets have changed.

open Unit

Called when the Behavior has been attached to a LayoutParams instance.

open Boolean
onDependentViewChanged(@NonNull parent: CoordinatorLayout, @NonNull child: V, @NonNull dependency: View)

Respond to a change in a child's dependent view

open Unit
onDependentViewRemoved(@NonNull parent: CoordinatorLayout, @NonNull child: V, @NonNull dependency: View)

Respond to a child's dependent view being removed.

open Unit

Called when the Behavior has been detached from its holding LayoutParams instance.

open Boolean
onInterceptTouchEvent(@NonNull parent: CoordinatorLayout, @NonNull child: V, @NonNull ev: MotionEvent)

Respond to CoordinatorLayout touch events before they are dispatched to child views.

open Boolean
onLayoutChild(@NonNull parent: CoordinatorLayout, @NonNull child: V, layoutDirection: Int)

Called when the parent CoordinatorLayout is about the lay out the given child view.

open Boolean