# CoordinatorLayout.Behavior

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:coordinatorlayout:28.0.0-alpha1  
Summary:[Ctors](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#pubctors)\|[Methods](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#)  

# CoordinatorLayout.Behavior

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public
static

abstract
class
CoordinatorLayout.Behavior
`  
`

extends Object


``


`

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| java.lang.Object                                                                                                                                            ||
| ↳ | android.support.design.widget.CoordinatorLayout.Behavior\<V extends[android.view.View](https://developer.android.com/reference/android/view/View.html)\> |

<br />

*** ** * ** ***

Interaction behavior plugin for child views of[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/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.

<br />

## Summary

|                                                                                                                                                                                                                          ### Public constructors                                                                                                                                                                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[CoordinatorLayout.Behavior](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#CoordinatorLayout.Behavior())`() ` Default constructor for instantiating Behaviors.                                                                                                                                                                                                                                                    |
| ` `[CoordinatorLayout.Behavior](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#CoordinatorLayout.Behavior(android.content.Context, android.util.AttributeSet))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)` attrs) ` Default constructor for inflating Behaviors from layout. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ||
|-------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` boolean`                                                                                                  | ` `[blocksInteractionBelow](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#blocksInteractionBelow(android.support.design.widget.CoordinatorLayout, V))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child) ` Determine whether interaction with views behind the given child in the child order should be blocked.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` boolean`                                                                                                  | ` `[getInsetDodgeRect](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#getInsetDodgeRect(android.support.design.widget.CoordinatorLayout, V, android.graphics.Rect))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child, `[Rect](https://developer.android.com/reference/android/graphics/Rect.html)` rect) ` Called when a view is set to dodge view insets.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` int`                                                                                                      | ` `[getScrimColor](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#getScrimColor(android.support.design.widget.CoordinatorLayout, V))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child) ` Supply a scrim color that will be painted behind the associated child view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` float`                                                                                                    | ` `[getScrimOpacity](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#getScrimOpacity(android.support.design.widget.CoordinatorLayout, V))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/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](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#getTag(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View.html)` child) ` Get the behavior-specific tag object with the given child view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` boolean`                                                                                                  | ` `[layoutDependsOn](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#layoutDependsOn(android.support.design.widget.CoordinatorLayout, V, android.view.View))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child, `[View](https://developer.android.com/reference/android/view/View.html)` dependency) ` Determine whether the supplied child view has another specific sibling view as a layout dependency.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` `[WindowInsetsCompat](https://developer.android.com/reference/android/support/v4/view/WindowInsetsCompat) | ` `[onApplyWindowInsets](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onApplyWindowInsets(android.support.design.widget.CoordinatorLayout, V, android.support.v4.view.WindowInsetsCompat))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[WindowInsetsCompat](https://developer.android.com/reference/android/support/v4/view/WindowInsetsCompat)` insets) ` Called when the window insets have changed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` void`                                                                                                     | ` `[onAttachedToLayoutParams](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onAttachedToLayoutParams(android.support.design.widget.CoordinatorLayout.LayoutParams))`(`[CoordinatorLayout.LayoutParams](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.LayoutParams)` params) ` Called when the Behavior has been attached to a LayoutParams instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` boolean`                                                                                                  | ` `[onDependentViewChanged](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onDependentViewChanged(android.support.design.widget.CoordinatorLayout, V, android.view.View))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child, `[View](https://developer.android.com/reference/android/view/View.html)` dependency) ` 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                                                     | ` `[onDependentViewRemoved](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onDependentViewRemoved(android.support.design.widget.CoordinatorLayout, V, android.view.View))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child, `[View](https://developer.android.com/reference/android/view/View.html)` dependency) ` Respond to a child's dependent view being removed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` void`                                                                                                     | ` `[onDetachedFromLayoutParams](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onDetachedFromLayoutParams())`() ` Called when the Behavior has been detached from its holding LayoutParams instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` boolean`                                                                                                  | ` `[onInterceptTouchEvent](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onInterceptTouchEvent(android.support.design.widget.CoordinatorLayout, V, android.view.MotionEvent))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child, `[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` ev) ` Respond to CoordinatorLayout touch events before they are dispatched to child views.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` boolean`                                                                                                  | ` `[onLayoutChild](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onLayoutChild(android.support.design.widget.CoordinatorLayout, V, int))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child, int layoutDirection) ` Called when the parent CoordinatorLayout is about the lay out the given child view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` boolean`                                                                                                  | ` `[onMeasureChild](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onMeasureChild(android.support.design.widget.CoordinatorLayout, V, int, int, int, int))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) ` Called when the parent CoordinatorLayout is about to measure the given child view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` boolean`                                                                                                  | ` `[onNestedFling](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedFling(android.support.design.widget.CoordinatorLayout, V, android.view.View, float, float, boolean))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` target, float velocityX, float velocityY, boolean consumed) ` Called when a nested scrolling child is starting a fling or an action that would be a fling.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` boolean`                                                                                                  | ` `[onNestedPreFling](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedPreFling(android.support.design.widget.CoordinatorLayout, V, android.view.View, float, float))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` target, float velocityX, float velocityY) ` Called when a nested scrolling child is about to start a fling.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` void`                                                                                                     | ` `[onNestedPreScroll](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedPreScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int, int, int[]))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` target, int dx, int dy, int[] consumed) ` *This method was deprecated in API level 26.1.0. You should now override[onNestedPreScroll(CoordinatorLayout, View, View, int, int, int[], int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedPreScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int, int, int[], int)). This method will still continue to be called if the type is[TYPE_TOUCH](https://developer.android.com/reference/android/support/v4/view/ViewCompat#TYPE_TOUCH).*                                                                                                   |
| ` void`                                                                                                     | ` `[onNestedPreScroll](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedPreScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int, int, int[], int))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` target, int dx, int dy, int[] consumed, int type) ` Called when a nested scroll in progress is about to update, before the target has consumed any of the scrolled distance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                     | ` `[onNestedScroll](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int, int, int, int))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) ` *This method was deprecated in API level 26.1.0. You should now override[onNestedScroll(CoordinatorLayout, View, View, int, int, int, int, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int, int, int, int, int)). This method will still continue to be called if the type is[TYPE_TOUCH](https://developer.android.com/reference/android/support/v4/view/ViewCompat#TYPE_TOUCH).*                                                                  |
| ` void`                                                                                                     | ` `[onNestedScroll](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int, int, int, int, int))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) ` Called when a nested scroll in progress has updated and the target has scrolled or attempted to scroll.                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                     | ` `[onNestedScrollAccepted](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedScrollAccepted(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int, int))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` directTargetChild, `[View](https://developer.android.com/reference/android/view/View.html)` target, int axes, int type) ` Called when a nested scroll has been accepted by the CoordinatorLayout.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` void`                                                                                                     | ` `[onNestedScrollAccepted](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedScrollAccepted(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` directTargetChild, `[View](https://developer.android.com/reference/android/view/View.html)` target, int axes) ` *This method was deprecated in API level 26.1.0. You should now override[onNestedScrollAccepted(CoordinatorLayout, View, View, View, int, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedScrollAccepted(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int, int)). This method will still continue to be called if the type is[TYPE_TOUCH](https://developer.android.com/reference/android/support/v4/view/ViewCompat#TYPE_TOUCH).* |
| ` boolean`                                                                                                  | ` `[onRequestChildRectangleOnScreen](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onRequestChildRectangleOnScreen(android.support.design.widget.CoordinatorLayout, V, android.graphics.Rect, boolean))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[Rect](https://developer.android.com/reference/android/graphics/Rect.html)` rectangle, boolean immediate) ` Called when a child of the view associated with this behavior wants a particular rectangle to be positioned onto the screen.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` void`                                                                                                     | ` `[onRestoreInstanceState](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onRestoreInstanceState(android.support.design.widget.CoordinatorLayout, V, android.os.Parcelable))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child, `[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)` state) ` Hook allowing a behavior to re-apply a representation of its internal state that had previously been generated by[onSaveInstanceState(CoordinatorLayout, V)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onSaveInstanceState(android.support.design.widget.CoordinatorLayout, V)).                                                                                                                                                                                                                                                                                                                                    |
| ` `[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)                         | ` `[onSaveInstanceState](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onSaveInstanceState(android.support.design.widget.CoordinatorLayout, V))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child) ` 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` boolean`                                                                                                  | ` `[onStartNestedScroll](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStartNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` directTargetChild, `[View](https://developer.android.com/reference/android/view/View.html)` target, int axes) ` *This method was deprecated in API level 26.1.0. You should now override[onStartNestedScroll(CoordinatorLayout, View, View, View, int, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStartNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int, int)). This method will still continue to be called if the type is[TYPE_TOUCH](https://developer.android.com/reference/android/support/v4/view/ViewCompat#TYPE_TOUCH).*             |
| ` boolean`                                                                                                  | ` `[onStartNestedScroll](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStartNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int, int))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` directTargetChild, `[View](https://developer.android.com/reference/android/view/View.html)` target, int axes, int type) ` Called when a descendant of the CoordinatorLayout attempts to initiate a nested scroll.                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`                                                                                                     | ` `[onStopNestedScroll](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStopNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` target) ` *This method was deprecated in API level 26.1.0. You should now override[onStopNestedScroll(CoordinatorLayout, View, View, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStopNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int)). This method will still continue to be called if the type is[TYPE_TOUCH](https://developer.android.com/reference/android/support/v4/view/ViewCompat#TYPE_TOUCH).*                                                                                                                                                                                  |
| ` void`                                                                                                     | ` `[onStopNestedScroll](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStopNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` coordinatorLayout, V child, `[View](https://developer.android.com/reference/android/view/View.html)` target, int type) ` Called when a nested scroll has ended.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` boolean`                                                                                                  | ` `[onTouchEvent](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onTouchEvent(android.support.design.widget.CoordinatorLayout, V, android.view.MotionEvent))`(`[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)` parent, V child, `[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)` ev) ` Respond to CoordinatorLayout touch events after this Behavior has started[intercepting](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onInterceptTouchEvent(android.support.design.widget.CoordinatorLayout, V, android.view.MotionEvent))them.                                                                                                                                                                                                                                                                                                                                                                                         |
| ` static void`                                                                                              | ` `[setTag](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#setTag(android.view.View, java.lang.Object))`(`[View](https://developer.android.com/reference/android/view/View.html)` child, Object tag) ` Associate a Behavior-specific tag object with the given child view.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public constructors

### CoordinatorLayout.Behavior

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CoordinatorLayout.Behavior ()
```

Default constructor for instantiating Behaviors.

<br />

### CoordinatorLayout.Behavior

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CoordinatorLayout.Behavior (Context context, 
                AttributeSet attrs)
```

Default constructor for inflating Behaviors from layout. The Behavior will have the opportunity to parse specially defined layout parameters. These parameters will appear on the child view tag.

<br />

## Public methods

### blocksInteractionBelow

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean blocksInteractionBelow (CoordinatorLayout parent, 
                V child)
```

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

The default implementation returns true if[getScrimOpacity(CoordinatorLayout, View)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#getScrimOpacity(android.support.design.widget.CoordinatorLayout, V))would return \> 0.0f.

<br />

<br />

|                                Parameters                                ||
|----------|----------------------------------------------------------------|
| `parent` | `CoordinatorLayout`: the parent view of the given child <br /> |
| `child`  | `V`: the child view to test <br />                             |

|                                                                                                                            Returns                                                                                                                             ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | true if[getScrimOpacity(CoordinatorLayout, View)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#getScrimOpacity(android.support.design.widget.CoordinatorLayout, V))would return \> 0.0f. <br /> |

### getInsetDodgeRect

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Called when a view is set to dodge view insets.

This method allows a behavior to update the rectangle that should be dodged. The rectangle should be in the parent's coordinate system and within the child's bounds. If not, a[IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException)is thrown.

<br />

<br />

|                                                   Parameters                                                    ||
|----------|-------------------------------------------------------------------------------------------------------|
| `parent` | `CoordinatorLayout`: the CoordinatorLayout parent of the view this Behavior is associated with <br /> |
| `child`  | `V`: the child view of the CoordinatorLayout this Behavior is associated with <br />                  |
| `rect`   | `Rect`: the rect to update with the dodge rectangle <br />                                            |

|                                        Returns                                         ||
|-----------|-----------------------------------------------------------------------------|
| `boolean` | true the rect was updated, false if we should use the child's bounds <br /> |

### getScrimColor

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int getScrimColor (CoordinatorLayout parent, 
                V child)
```

Supply a scrim color that will be painted behind the associated 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.

The default implementation returns[BLACK](https://developer.android.com/reference/android/graphics/Color.html#BLACK).

<br />

<br />

|                                Parameters                                ||
|----------|----------------------------------------------------------------|
| `parent` | `CoordinatorLayout`: the parent view of the given child <br /> |
| `child`  | `V`: the child view above the scrim <br />                     |

|                                                                                  Returns                                                                                   ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | the desired scrim color in 0xAARRGGBB format. The default return value is[BLACK](https://developer.android.com/reference/android/graphics/Color.html#BLACK). <br /> |

**See also:**

- [getScrimOpacity(CoordinatorLayout, View)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#getScrimOpacity(android.support.design.widget.CoordinatorLayout, V))  

### getScrimOpacity

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

The default implementation returns 0.0f.

<br />

<br />

|                                Parameters                                ||
|----------|----------------------------------------------------------------|
| `parent` | `CoordinatorLayout`: the parent view of the given child <br /> |
| `child`  | `V`: the child view above the scrim <br />                     |

|                                                             Returns                                                             ||
|---------|------------------------------------------------------------------------------------------------------------------------|
| `float` | the desired scrim opacity from 0.0f to 1.0f. The default return value is 0.0f. Value is between 0.0 and 1.0 inclusive. |

### getTag

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Object getTag (View child)
```

Get the behavior-specific tag object with the given child view. This object is stored with the child view's LayoutParams.

<br />

|                     Parameters                     ||
|---------|-------------------------------------------|
| `child` | `View`: child view to get tag with <br /> |

|                      Returns                      ||
|----------|-----------------------------------------|
| `Object` | the previously stored tag object <br /> |

### layoutDependsOn

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

This method will be called at least once in response to a layout request. If it returns true for a given child and dependency view pair, the parent CoordinatorLayout will:

1. Always lay out this child after the dependent child is laid out, regardless of child order.
2. Call[onDependentViewChanged(CoordinatorLayout, V, View)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onDependentViewChanged(android.support.design.widget.CoordinatorLayout, V, android.view.View))when the dependency view's layout or position changes.

<br />

<br />

|                                  Parameters                                  ||
|--------------|----------------------------------------------------------------|
| `parent`     | `CoordinatorLayout`: the parent view of the given child <br /> |
| `child`      | `V`: the child view to test <br />                             |
| `dependency` | `View`: the proposed dependency of child <br />                |

|                                                Returns                                                ||
|-----------|--------------------------------------------------------------------------------------------|
| `boolean` | true if child's layout depends on the proposed dependency's layout, false otherwise <br /> |

**See also:**

- [onDependentViewChanged(CoordinatorLayout, View, View)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onDependentViewChanged(android.support.design.widget.CoordinatorLayout, V, android.view.View))  

### onApplyWindowInsets

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Called when the window insets have changed.

Any Behavior associated with the direct child of the CoordinatorLayout may elect to handle the window inset change on behalf of it's associated view.

<br />

<br />

|                                                         Parameters                                                         ||
|---------------------|-------------------------------------------------------------------------------------------------------|
| `coordinatorLayout` | `CoordinatorLayout`: the CoordinatorLayout parent of the view this Behavior is associated with <br /> |
| `child`             | `V`: the child view of the CoordinatorLayout this Behavior is associated with <br />                  |
| `insets`            | `WindowInsetsCompat`: the new window insets. <br />                                                   |

|                                                                                  Returns                                                                                  ||
|----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [WindowInsetsCompat](https://developer.android.com/reference/android/support/v4/view/WindowInsetsCompat) | The insets supplied, minus any insets that were consumed <br /> |

### onAttachedToLayoutParams

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onAttachedToLayoutParams (CoordinatorLayout.LayoutParams params)
```

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

This will be called after the LayoutParams has been instantiated and can be modified.

<br />

<br />

|                                                      Parameters                                                      ||
|----------|------------------------------------------------------------------------------------------------------------|
| `params` | `CoordinatorLayout.LayoutParams`: the LayoutParams instance that this Behavior has been attached to <br /> |

### onDependentViewChanged

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onDependentViewChanged (CoordinatorLayout parent, 
                V child, 
                View dependency)
```

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. A Behavior may use this method to appropriately update the child view in response.

A view's dependency is determined by[layoutDependsOn(CoordinatorLayout, View, View)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#layoutDependsOn(android.support.design.widget.CoordinatorLayout, V, android.view.View))or if`child`has set another view as it's anchor.

Note that if a Behavior changes the layout of a child via this method, it should also be able to reconstruct the correct position in[onLayoutChild](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onLayoutChild(android.support.design.widget.CoordinatorLayout, V, int)).`onDependentViewChanged`will not be called during normal layout since the layout of each child view will always happen in dependency order.

If the Behavior changes the child view's size or position, it should return true. The default implementation returns false.

<br />

<br />

|                                  Parameters                                  ||
|--------------|----------------------------------------------------------------|
| `parent`     | `CoordinatorLayout`: the parent view of the given child <br /> |
| `child`      | `V`: the child view to manipulate <br />                       |
| `dependency` | `View`: the dependent view that changed <br />                 |

|                                              Returns                                              ||
|-----------|----------------------------------------------------------------------------------------|
| `boolean` | true if the Behavior changed the child view's size or position, false otherwise <br /> |

### onDependentViewRemoved

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onDependentViewRemoved (CoordinatorLayout parent, 
                V child, 
                View dependency)
```

Respond to a child's dependent view being removed.

This method is called after a dependent view has been removed from the parent. A Behavior may use this method to appropriately update the child view in response.

A view's dependency is determined by[layoutDependsOn(CoordinatorLayout, View, View)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#layoutDependsOn(android.support.design.widget.CoordinatorLayout, V, android.view.View))or if`child`has set another view as it's anchor.

<br />

<br />

|                                  Parameters                                  ||
|--------------|----------------------------------------------------------------|
| `parent`     | `CoordinatorLayout`: the parent view of the given child <br /> |
| `child`      | `V`: the child view to manipulate <br />                       |
| `dependency` | `View`: the dependent view that has been removed <br />        |

### onDetachedFromLayoutParams

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onDetachedFromLayoutParams ()
```

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

This will only be called if the Behavior has been explicitly removed from the LayoutParams instance via[setBehavior(Behavior)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.LayoutParams#setBehavior(android.support.design.widget.CoordinatorLayout.Behavior)). It will not be called if the associated view is removed from the CoordinatorLayout or similar.

<br />

<br />

### onInterceptTouchEvent

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onInterceptTouchEvent (CoordinatorLayout parent, 
                V child, 
                MotionEvent ev)
```

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

Behaviors can use this to monitor inbound touch events until one decides to intercept the rest of the event stream to take an action on its associated child view. This method will return false until it detects the proper intercept conditions, then return true once those conditions have occurred.

Once a Behavior intercepts touch events, the rest of the event stream will be sent to the[onTouchEvent(CoordinatorLayout, V, MotionEvent)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onTouchEvent(android.support.design.widget.CoordinatorLayout, V, android.view.MotionEvent))method.

This method will be called regardless of the visibility of the associated child of the behavior. If you only wish to handle touch events when the child is visible, you should add a check to[isShown()](https://developer.android.com/reference/android/view/View.html#isShown())on the given child.

The default implementation of this method always returns false.

<br />

<br />

|                                         Parameters                                         ||
|----------|----------------------------------------------------------------------------------|
| `parent` | `CoordinatorLayout`: the parent view currently receiving this touch event <br /> |
| `child`  | `V`: the child view associated with this Behavior <br />                         |
| `ev`     | `MotionEvent`: the MotionEvent describing the touch event being processed <br /> |

|                                                              Returns                                                              ||
|-----------|------------------------------------------------------------------------------------------------------------------------|
| `boolean` | true if this Behavior would like to intercept and take over the event stream. The default always returns false. <br /> |

### onLayoutChild

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onLayoutChild (CoordinatorLayout parent, 
                V child, 
                int layoutDirection)
```

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

This method can be used to perform custom or modified layout of a child view in place of the default child layout behavior. The Behavior's implementation can delegate to the standard CoordinatorLayout measurement behavior by calling[parent.onLayoutChild](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout#onLayoutChild(android.view.View, int)).

If a Behavior implements[onDependentViewChanged(CoordinatorLayout, View, View)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onDependentViewChanged(android.support.design.widget.CoordinatorLayout, V, android.view.View))to change the position of a view in response to a dependent view changing, it should also implement`onLayoutChild`in such a way that respects those dependent views.`onLayoutChild`will always be called for a dependent view*after*its dependency has been laid out.

<br />

<br />

|                                                                                                                                                                     Parameters                                                                                                                                                                     ||
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `parent`          | `CoordinatorLayout`: the parent CoordinatorLayout <br />                                                                                                                                                                                                                                                                        |
| `child`           | `V`: child view to lay out <br />                                                                                                                                                                                                                                                                                               |
| `layoutDirection` | `int`: the resolved layout direction for the CoordinatorLayout, such as[LAYOUT_DIRECTION_LTR](https://developer.android.com/reference/android/support/v4/view/ViewCompat#LAYOUT_DIRECTION_LTR)or[LAYOUT_DIRECTION_RTL](https://developer.android.com/reference/android/support/v4/view/ViewCompat#LAYOUT_DIRECTION_RTL). <br /> |

|                                                       Returns                                                       ||
|-----------|----------------------------------------------------------------------------------------------------------|
| `boolean` | true if the Behavior performed layout of the child view, false to request default layout behavior <br /> |

### onMeasureChild

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onMeasureChild (CoordinatorLayout parent, 
                V child, 
                int parentWidthMeasureSpec, 
                int widthUsed, 
                int parentHeightMeasureSpec, 
                int heightUsed)
```

Called when the parent CoordinatorLayout is about to measure the given child view.

This method can be used to perform custom or modified measurement of a child view in place of the default child measurement behavior. The Behavior's implementation can delegate to the standard CoordinatorLayout measurement behavior by calling[parent.onMeasureChild](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout#onMeasureChild(android.view.View, int, int, int, int)).

<br />

<br />

|                                                                    Parameters                                                                    ||
|---------------------------|-----------------------------------------------------------------------------------------------------------------------|
| `parent`                  | `CoordinatorLayout`: the parent CoordinatorLayout <br />                                                              |
| `child`                   | `V`: the child to measure <br />                                                                                      |
| `parentWidthMeasureSpec`  | `int`: the width requirements for this view <br />                                                                    |
| `widthUsed`               | `int`: extra space that has been used up by the parent horizontally (possibly by other children of the parent) <br /> |
| `parentHeightMeasureSpec` | `int`: the height requirements for this view <br />                                                                   |
| `heightUsed`              | `int`: extra space that has been used up by the parent vertically (possibly by other children of the parent) <br />   |

|                                                                Returns                                                                ||
|-----------|----------------------------------------------------------------------------------------------------------------------------|
| `boolean` | true if the Behavior measured the child view, false if the CoordinatorLayout should perform its default measurement <br /> |

### onNestedFling

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onNestedFling (CoordinatorLayout coordinatorLayout, 
                V child, 
                View target, 
                float velocityX, 
                float velocityY, 
                boolean consumed)
```

Called when a nested scrolling child is starting a fling or an action that would be a fling.

Any Behavior associated with the direct child of the CoordinatorLayout may elect to accept the nested scroll as part of[onStartNestedScroll(CoordinatorLayout, V, View, View, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStartNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int)). Each Behavior that returned true will receive subsequent nested scroll events for that nested scroll.

`onNestedFling`is called when the current nested scrolling child view detects the proper conditions for a fling. It reports if the child itself consumed the fling. If it did not, the child is expected to show some sort of overscroll indication. This method should return true if it consumes the fling, so that a child that did not itself take an action in response can choose not to show an overfling indication.

<br />

<br />

|                                                         Parameters                                                         ||
|---------------------|-------------------------------------------------------------------------------------------------------|
| `coordinatorLayout` | `CoordinatorLayout`: the CoordinatorLayout parent of the view this Behavior is associated with <br /> |
| `child`             | `V`: the child view of the CoordinatorLayout this Behavior is associated with <br />                  |
| `target`            | `View`: the descendant view of the CoordinatorLayout performing the nested scroll <br />              |
| `velocityX`         | `float`: horizontal velocity of the attempted fling <br />                                            |
| `velocityY`         | `float`: vertical velocity of the attempted fling <br />                                              |
| `consumed`          | `boolean`: true if the nested child view consumed the fling <br />                                    |

|                          Returns                          ||
|-----------|------------------------------------------------|
| `boolean` | true if the Behavior consumed the fling <br /> |

**See also:**

- [onNestedFling(View, float, float, boolean)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingParent#onNestedFling(android.view.View, float, float, boolean))  

### onNestedPreFling

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onNestedPreFling (CoordinatorLayout coordinatorLayout, 
                V child, 
                View target, 
                float velocityX, 
                float velocityY)
```

Called when a nested scrolling child is about to start a fling.

Any Behavior associated with the direct child of the CoordinatorLayout may elect to accept the nested scroll as part of[onStartNestedScroll(CoordinatorLayout, V, View, View, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStartNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int)). Each Behavior that returned true will receive subsequent nested scroll events for that nested scroll.

`onNestedPreFling`is called when the current nested scrolling child view detects the proper conditions for a fling, but it has not acted on it yet. A Behavior can return true to indicate that it consumed the fling. If at least one Behavior returns true, the fling should not be acted upon by the child.

<br />

<br />

|                                                         Parameters                                                         ||
|---------------------|-------------------------------------------------------------------------------------------------------|
| `coordinatorLayout` | `CoordinatorLayout`: the CoordinatorLayout parent of the view this Behavior is associated with <br /> |
| `child`             | `V`: the child view of the CoordinatorLayout this Behavior is associated with <br />                  |
| `target`            | `View`: the descendant view of the CoordinatorLayout performing the nested scroll <br />              |
| `velocityX`         | `float`: horizontal velocity of the attempted fling <br />                                            |
| `velocityY`         | `float`: vertical velocity of the attempted fling <br />                                              |

|                          Returns                          ||
|-----------|------------------------------------------------|
| `boolean` | true if the Behavior consumed the fling <br /> |

**See also:**

- [onNestedPreFling(View, float, float)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingParent#onNestedPreFling(android.view.View, float, float))  

### onNestedPreScroll

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onNestedPreScroll (CoordinatorLayout coordinatorLayout, 
                V child, 
                View target, 
                int dx, 
                int dy, 
                int[] consumed)
```

<br />

**This method was deprecated in API level 26.1.0.**   
You should now override[onNestedPreScroll(CoordinatorLayout, View, View, int, int, int[], int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedPreScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int, int, int[], int)). This method will still continue to be called if the type is[TYPE_TOUCH](https://developer.android.com/reference/android/support/v4/view/ViewCompat#TYPE_TOUCH).

<br />

<br />

|                   Parameters                    ||
|---------------------|----------------------------|
| `coordinatorLayout` | `CoordinatorLayout` <br /> |
| `child`             | `V` <br />                 |
| `target`            | `View` <br />              |
| `dx`                | `int` <br />               |
| `dy`                | `int` <br />               |
| `consumed`          | `int` <br />               |

### onNestedPreScroll

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onNestedPreScroll (CoordinatorLayout coordinatorLayout, 
                V child, 
                View target, 
                int dx, 
                int dy, 
                int[] consumed, 
                int type)
```

Called when a nested scroll in progress is about to update, before the target has consumed any of the scrolled distance.

Any Behavior associated with the direct child of the CoordinatorLayout may elect to accept the nested scroll as part of[onStartNestedScroll(CoordinatorLayout, V, View, View, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStartNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int)). Each Behavior that returned true will receive subsequent nested scroll events for that nested scroll.

`onNestedPreScroll`is called each time the nested scroll is updated by the nested scrolling child, before the nested scrolling child has consumed the scroll distance itself.*Each Behavior responding to the nested scroll will receive the same values.*The CoordinatorLayout will report as consumed the maximum number of pixels in either direction that any Behavior responding to the nested scroll reported as consumed.

<br />

<br />

|                                                                                         Parameters                                                                                         ||
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `coordinatorLayout` | `CoordinatorLayout`: the CoordinatorLayout parent of the view this Behavior is associated with <br />                                                                 |
| `child`             | `V`: the child view of the CoordinatorLayout this Behavior is associated with <br />                                                                                  |
| `target`            | `View`: the descendant view of the CoordinatorLayout performing the nested scroll <br />                                                                              |
| `dx`                | `int`: the raw horizontal number of pixels that the user attempted to scroll <br />                                                                                   |
| `dy`                | `int`: the raw vertical number of pixels that the user attempted to scroll <br />                                                                                     |
| `consumed`          | `int`: out parameter. consumed\[0\] should be set to the distance of dx that was consumed, consumed\[1\] should be set to the distance of dy that was consumed <br /> |
| `type`              | `int`: the type of input which cause this scroll event <br />                                                                                                         |

**See also:**

- [onNestedPreScroll(View, int, int, int[], int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingParent2#onNestedPreScroll(android.view.View, int, int, int[], int))  

### onNestedScroll

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onNestedScroll (CoordinatorLayout coordinatorLayout, 
                V child, 
                View target, 
                int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed)
```

<br />

**This method was deprecated in API level 26.1.0.**   
You should now override[onNestedScroll(CoordinatorLayout, View, View, int, int, int, int, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int, int, int, int, int)). This method will still continue to be called if the type is[TYPE_TOUCH](https://developer.android.com/reference/android/support/v4/view/ViewCompat#TYPE_TOUCH).

<br />

<br />

|                   Parameters                    ||
|---------------------|----------------------------|
| `coordinatorLayout` | `CoordinatorLayout` <br /> |
| `child`             | `V` <br />                 |
| `target`            | `View` <br />              |
| `dxConsumed`        | `int` <br />               |
| `dyConsumed`        | `int` <br />               |
| `dxUnconsumed`      | `int` <br />               |
| `dyUnconsumed`      | `int` <br />               |

### onNestedScroll

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onNestedScroll (CoordinatorLayout coordinatorLayout, 
                V child, 
                View target, 
                int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed, 
                int type)
```

Called when a nested scroll in progress has updated and the target has scrolled or attempted to scroll.

Any Behavior associated with the direct child of the CoordinatorLayout may elect to accept the nested scroll as part of[onStartNestedScroll(CoordinatorLayout, V, View, View, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStartNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int)). Each Behavior that returned true will receive subsequent nested scroll events for that nested scroll.

`onNestedScroll`is called each time the nested scroll is updated by the nested scrolling child, with both consumed and unconsumed components of the scroll supplied in pixels.*Each Behavior responding to the nested scroll will receive the same values.*

<br />

<br />

|                                                              Parameters                                                              ||
|---------------------|-----------------------------------------------------------------------------------------------------------------|
| `coordinatorLayout` | `CoordinatorLayout`: the CoordinatorLayout parent of the view this Behavior is associated with <br />           |
| `child`             | `V`: the child view of the CoordinatorLayout this Behavior is associated with <br />                            |
| `target`            | `View`: the descendant view of the CoordinatorLayout performing the nested scroll <br />                        |
| `dxConsumed`        | `int`: horizontal pixels consumed by the target's own scrolling operation <br />                                |
| `dyConsumed`        | `int`: vertical pixels consumed by the target's own scrolling operation <br />                                  |
| `dxUnconsumed`      | `int`: horizontal pixels not consumed by the target's own scrolling operation, but requested by the user <br /> |
| `dyUnconsumed`      | `int`: vertical pixels not consumed by the target's own scrolling operation, but requested by the user <br />   |
| `type`              | `int`: the type of input which cause this scroll event <br />                                                   |

**See also:**

- [onNestedScroll(View, int, int, int, int, int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingParent2#onNestedScroll(android.view.View, int, int, int, int, int))  

### onNestedScrollAccepted

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onNestedScrollAccepted (CoordinatorLayout coordinatorLayout, 
                V child, 
                View directTargetChild, 
                View target, 
                int axes, 
                int type)
```

Called when a nested scroll has been accepted by the CoordinatorLayout.

Any Behavior associated with any direct child of the CoordinatorLayout may elect to accept the nested scroll as part of[onStartNestedScroll(CoordinatorLayout, V, View, View, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStartNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int)). Each Behavior that returned true will receive subsequent nested scroll events for that nested scroll.

<br />

<br />

|                                                                                                                                                               Parameters                                                                                                                                                               ||
|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `coordinatorLayout` | `CoordinatorLayout`: the CoordinatorLayout parent of the view this Behavior is associated with <br />                                                                                                                                                                                                             |
| `child`             | `V`: the child view of the CoordinatorLayout this Behavior is associated with <br />                                                                                                                                                                                                                              |
| `directTargetChild` | `View`: the child view of the CoordinatorLayout that either is or contains the target of the nested scroll operation <br />                                                                                                                                                                                       |
| `target`            | `View`: the descendant view of the CoordinatorLayout initiating the nested scroll <br />                                                                                                                                                                                                                          |
| `axes`              | `int`: the axes that this nested scroll applies to. See[SCROLL_AXIS_HORIZONTAL](https://developer.android.com/reference/android/support/v4/view/ViewCompat#SCROLL_AXIS_HORIZONTAL),[SCROLL_AXIS_VERTICAL](https://developer.android.com/reference/android/support/v4/view/ViewCompat#SCROLL_AXIS_VERTICAL) <br /> |
| `type`              | `int`: the type of input which cause this scroll event <br />                                                                                                                                                                                                                                                     |

**See also:**

- [onNestedScrollAccepted(View, View, int, int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingParent2#onNestedScrollAccepted(android.view.View, android.view.View, int, int))  

### onNestedScrollAccepted

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onNestedScrollAccepted (CoordinatorLayout coordinatorLayout, 
                V child, 
                View directTargetChild, 
                View target, 
                int axes)
```

<br />

**This method was deprecated in API level 26.1.0.**   
You should now override[onNestedScrollAccepted(CoordinatorLayout, View, View, View, int, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onNestedScrollAccepted(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int, int)). This method will still continue to be called if the type is[TYPE_TOUCH](https://developer.android.com/reference/android/support/v4/view/ViewCompat#TYPE_TOUCH).

<br />

<br />

|                   Parameters                    ||
|---------------------|----------------------------|
| `coordinatorLayout` | `CoordinatorLayout` <br /> |
| `child`             | `V` <br />                 |
| `directTargetChild` | `View` <br />              |
| `target`            | `View` <br />              |
| `axes`              | `int` <br />               |

### onRequestChildRectangleOnScreen

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onRequestChildRectangleOnScreen (CoordinatorLayout coordinatorLayout, 
                V child, 
                Rect rectangle, 
                boolean immediate)
```

Called when a child of the view associated with this behavior wants a particular rectangle to be positioned onto the screen.

The contract for this method is the same as[requestChildRectangleOnScreen(View, Rect, boolean)](https://developer.android.com/reference/android/view/ViewParent.html#requestChildRectangleOnScreen(android.view.View, android.graphics.Rect, boolean)).

<br />

<br />

|                                                         Parameters                                                         ||
|---------------------|-------------------------------------------------------------------------------------------------------|
| `coordinatorLayout` | `CoordinatorLayout`: the CoordinatorLayout parent of the view this Behavior is associated with <br /> |
| `child`             | `V`: the child view of the CoordinatorLayout this Behavior is associated with <br />                  |
| `rectangle`         | `Rect`: The rectangle which the child wishes to be on the screen in the child's coordinates <br />    |
| `immediate`         | `boolean`: true to forbid animated or delayed scrolling, false otherwise <br />                       |

|                          Returns                           ||
|-----------|-------------------------------------------------|
| `boolean` | true if the Behavior handled the request <br /> |

**See also:**

- [requestChildRectangleOnScreen(View, Rect, boolean)](https://developer.android.com/https://developer.android.com/reference/android/view/ViewParent#requestChildRectangleOnScreen(android.view.View, android.graphics.Rect, boolean))  

### onRestoreInstanceState

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onRestoreInstanceState (CoordinatorLayout parent, 
                V child, 
                Parcelable state)
```

Hook allowing a behavior to re-apply a representation of its internal state that had previously been generated by[onSaveInstanceState(CoordinatorLayout, V)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onSaveInstanceState(android.support.design.widget.CoordinatorLayout, V)). This function will never be called with a null state.

<br />

|                                                                                                                                                 Parameters                                                                                                                                                 ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `parent` | `CoordinatorLayout`: the parent CoordinatorLayout <br />                                                                                                                                                                                                                                         |
| `child`  | `V`: child view to restore from <br />                                                                                                                                                                                                                                                           |
| `state`  | `Parcelable`: The frozen state that had previously been returned by[onSaveInstanceState(CoordinatorLayout, V)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onSaveInstanceState(android.support.design.widget.CoordinatorLayout, V)). <br /> |

**See also:**

- [onSaveInstanceState()](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout#onSaveInstanceState())  

### onSaveInstanceState

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Parcelable onSaveInstanceState (CoordinatorLayout parent, 
                V child)
```

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. This state should only contain information that is not persistent or can not be reconstructed later.

Behavior state is only saved when both the parent[CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)and a view using this behavior have valid IDs set.

<br />

<br />

|                             Parameters                             ||
|----------|----------------------------------------------------------|
| `parent` | `CoordinatorLayout`: the parent CoordinatorLayout <br /> |
| `child`  | `V`: child view to restore from <br />                   |

|                                                                                Returns                                                                                ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
| [Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) | Returns a Parcelable object containing the behavior's current dynamic state. <br /> |

**See also:**

- [onRestoreInstanceState(Parcelable)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout#onRestoreInstanceState(android.os.Parcelable))
- [onSaveInstanceState()](https://developer.android.com/https://developer.android.com/reference/android/view/View#onSaveInstanceState())  

### onStartNestedScroll

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onStartNestedScroll (CoordinatorLayout coordinatorLayout, 
                V child, 
                View directTargetChild, 
                View target, 
                int axes)
```

<br />

**This method was deprecated in API level 26.1.0.**   
You should now override[onStartNestedScroll(CoordinatorLayout, View, View, View, int, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStartNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int, int)). This method will still continue to be called if the type is[TYPE_TOUCH](https://developer.android.com/reference/android/support/v4/view/ViewCompat#TYPE_TOUCH).

<br />

<br />

|                   Parameters                    ||
|---------------------|----------------------------|
| `coordinatorLayout` | `CoordinatorLayout` <br /> |
| `child`             | `V` <br />                 |
| `directTargetChild` | `View` <br />              |
| `target`            | `View` <br />              |
| `axes`              | `int` <br />               |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### onStartNestedScroll

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onStartNestedScroll (CoordinatorLayout coordinatorLayout, 
                V child, 
                View directTargetChild, 
                View target, 
                int axes, 
                int type)
```

Called when a descendant of the CoordinatorLayout attempts to initiate a nested scroll.

Any Behavior associated with any direct child of the CoordinatorLayout may respond to this event and return true to indicate that the CoordinatorLayout should act as a nested scrolling parent for this scroll. Only Behaviors that return true from this method will receive subsequent nested scroll events.

<br />

<br />

|                                                                                                                                                               Parameters                                                                                                                                                               ||
|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `coordinatorLayout` | `CoordinatorLayout`: the CoordinatorLayout parent of the view this Behavior is associated with <br />                                                                                                                                                                                                             |
| `child`             | `V`: the child view of the CoordinatorLayout this Behavior is associated with <br />                                                                                                                                                                                                                              |
| `directTargetChild` | `View`: the child view of the CoordinatorLayout that either is or contains the target of the nested scroll operation <br />                                                                                                                                                                                       |
| `target`            | `View`: the descendant view of the CoordinatorLayout initiating the nested scroll <br />                                                                                                                                                                                                                          |
| `axes`              | `int`: the axes that this nested scroll applies to. See[SCROLL_AXIS_HORIZONTAL](https://developer.android.com/reference/android/support/v4/view/ViewCompat#SCROLL_AXIS_HORIZONTAL),[SCROLL_AXIS_VERTICAL](https://developer.android.com/reference/android/support/v4/view/ViewCompat#SCROLL_AXIS_VERTICAL) <br /> |
| `type`              | `int`: the type of input which cause this scroll event <br />                                                                                                                                                                                                                                                     |

|                                  Returns                                   ||
|-----------|-----------------------------------------------------------------|
| `boolean` | true if the Behavior wishes to accept this nested scroll <br /> |

**See also:**

- [onStartNestedScroll(View, View, int, int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingParent2#onStartNestedScroll(android.view.View, android.view.View, int, int))  

### onStopNestedScroll

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onStopNestedScroll (CoordinatorLayout coordinatorLayout, 
                V child, 
                View target)
```

<br />

**This method was deprecated in API level 26.1.0.**   
You should now override[onStopNestedScroll(CoordinatorLayout, View, View, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStopNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, int)). This method will still continue to be called if the type is[TYPE_TOUCH](https://developer.android.com/reference/android/support/v4/view/ViewCompat#TYPE_TOUCH).

<br />

<br />

|                   Parameters                    ||
|---------------------|----------------------------|
| `coordinatorLayout` | `CoordinatorLayout` <br /> |
| `child`             | `V` <br />                 |
| `target`            | `View` <br />              |

### onStopNestedScroll

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onStopNestedScroll (CoordinatorLayout coordinatorLayout, 
                V child, 
                View target, 
                int type)
```

Called when a nested scroll has ended.

Any Behavior associated with any direct child of the CoordinatorLayout may elect to accept the nested scroll as part of[onStartNestedScroll(CoordinatorLayout, V, View, View, int)](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onStartNestedScroll(android.support.design.widget.CoordinatorLayout, V, android.view.View, android.view.View, int)). Each Behavior that returned true will receive subsequent nested scroll events for that nested scroll.

`onStopNestedScroll`marks the end of a single nested scroll event sequence. This is a good place to clean up any state related to the nested scroll.

<br />

<br />

|                                                         Parameters                                                         ||
|---------------------|-------------------------------------------------------------------------------------------------------|
| `coordinatorLayout` | `CoordinatorLayout`: the CoordinatorLayout parent of the view this Behavior is associated with <br /> |
| `child`             | `V`: the child view of the CoordinatorLayout this Behavior is associated with <br />                  |
| `target`            | `View`: the descendant view of the CoordinatorLayout that initiated the nested scroll <br />          |
| `type`              | `int`: the type of input which cause this scroll event <br />                                         |

**See also:**

- [onStopNestedScroll(View, int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingParent2#onStopNestedScroll(android.view.View, int))  

### onTouchEvent

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onTouchEvent (CoordinatorLayout parent, 
                V child, 
                MotionEvent ev)
```

Respond to CoordinatorLayout touch events after this Behavior has started[intercepting](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior#onInterceptTouchEvent(android.support.design.widget.CoordinatorLayout, V, android.view.MotionEvent))them.

Behaviors may intercept touch events in order to help the CoordinatorLayout manipulate its child views. For example, a Behavior may allow a user to drag a UI pane open or closed. This method should perform actual mutations of view layout state.

This method will be called regardless of the visibility of the associated child of the behavior. If you only wish to handle touch events when the child is visible, you should add a check to[isShown()](https://developer.android.com/reference/android/view/View.html#isShown())on the given child.

<br />

<br />

|                                         Parameters                                         ||
|----------|----------------------------------------------------------------------------------|
| `parent` | `CoordinatorLayout`: the parent view currently receiving this touch event <br /> |
| `child`  | `V`: the child view associated with this Behavior <br />                         |
| `ev`     | `MotionEvent`: the MotionEvent describing the touch event being processed <br /> |

|                                                                            Returns                                                                             ||
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | true if this Behavior handled this touch event and would like to continue receiving events in this stream. The default always returns false. <br /> |

### setTag

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setTag (View child, 
                Object tag)
```

Associate a Behavior-specific tag object with the given child view. This object will be stored with the child view's LayoutParams.

<br />

|                     Parameters                     ||
|---------|-------------------------------------------|
| `child` | `View`: child view to set tag with <br /> |
| `tag`   | `Object`: tag object to set <br />        |

-

  ## Annotations

  - [CoordinatorLayout.DefaultBehavior](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.DefaultBehavior)
-

  ## Interfaces

  - [CoordinatorLayout.AttachedBehavior](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.AttachedBehavior)
-

  ## Classes

  - [CoordinatorLayout](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout)
  - [CoordinatorLayout.Behavior](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior)
  - [CoordinatorLayout.LayoutParams](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.LayoutParams)
  - [CoordinatorLayout.SavedState](https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.SavedState)