public static abstract class CoordinatorLayout.Behavior
extends Object

   ↳ androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior<V extends android.view.View>

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.

Behavior(Context context, AttributeSet attrs)

Default constructor for inflating Behaviors from layout.

Public methods

boolean blocksInteractionBelow(CoordinatorLayout parent, V child)

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

boolean getInsetDodgeRect(CoordinatorLayout parent, V child, Rect rect)

Called when a view is set to dodge view insets.

int getScrimColor(CoordinatorLayout parent, V child)

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

float getScrimOpacity(CoordinatorLayout parent, V child)

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.

static Object getTag(View child)

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

boolean layoutDependsOn(CoordinatorLayout parent, V child, View dependency)

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

WindowInsetsCompat onApplyWindowInsets(CoordinatorLayout coordinatorLayout, V child, WindowInsetsCompat insets)

Called when the window insets have changed.