# NestedScrollingChild2

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1  
Summary:[Methods](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#)  

# NestedScrollingChild2

| 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


interface
NestedScrollingChild2
`  
`


implements

`[NestedScrollingChild](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild)`


`

|-----------------------------------------------|
| android.support.v4.view.NestedScrollingChild2 |

|---|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#)Known Indirect Subclasses [BaseGridView](https://developer.android.com/reference/android/support/v17/leanback/widget/BaseGridView),[HorizontalGridView](https://developer.android.com/reference/android/support/v17/leanback/widget/HorizontalGridView),[NestedScrollView](https://developer.android.com/reference/android/support/v4/widget/NestedScrollView),[RecyclerView](https://developer.android.com/reference/android/support/v7/widget/RecyclerView),[VerticalGridView](https://developer.android.com/reference/android/support/v17/leanback/widget/VerticalGridView),[WearableRecyclerView](https://developer.android.com/reference/android/support/wear/widget/WearableRecyclerView) |----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [BaseGridView](https://developer.android.com/reference/android/support/v17/leanback/widget/BaseGridView)             | An abstract base class for vertically and horizontally scrolling lists.                                                                                                                                                                                                                                                                                                        | | [HorizontalGridView](https://developer.android.com/reference/android/support/v17/leanback/widget/HorizontalGridView) | A[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)that shows items in a horizontal scrolling list.                                                                                                                                                                                                                                              | | [NestedScrollView](https://developer.android.com/reference/android/support/v4/widget/NestedScrollView)               | NestedScrollView is just like[ScrollView](https://developer.android.com/reference/android/widget/ScrollView.html), but it supports acting as both a nested scrolling parent and child on both new and old versions of Android.                                                                                                                                                 | | [RecyclerView](https://developer.android.com/reference/android/support/v7/widget/RecyclerView)                       | A flexible view for providing a limited window into a large data set.                                                                                                                                                                                                                                                                                                          | | [VerticalGridView](https://developer.android.com/reference/android/support/v17/leanback/widget/VerticalGridView)     | A[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)that shows items in a vertically scrolling list.                                                                                                                                                                                                                                              | | [WearableRecyclerView](https://developer.android.com/reference/android/support/wear/widget/WearableRecyclerView)     | Wearable specific implementation of the[RecyclerView](https://developer.android.com/reference/android/support/v7/widget/RecyclerView)enabling[setCircularScrollingGestureEnabled(boolean)](https://developer.android.com/reference/android/support/wear/widget/WearableRecyclerView#setCircularScrollingGestureEnabled(boolean))circular scrolling} and semi-circular layouts. | ||

<br />

*** ** * ** ***

This interface should be implemented by[View](https://developer.android.com/reference/android/view/View.html)subclasses that wish to support dispatching nested scrolling operations to a cooperating parent[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html).

Classes implementing this interface should create a final instance of a[NestedScrollingChildHelper](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChildHelper)as a field and delegate any View methods to the`NestedScrollingChildHelper`methods of the same signature.

Views invoking nested scrolling functionality should always do so from the relevant[ViewCompat](https://developer.android.com/reference/android/support/v4/view/ViewCompat),[ViewGroupCompat](https://developer.android.com/reference/android/support/v4/view/ViewGroupCompat)or[ViewParentCompat](https://developer.android.com/reference/android/support/v4/view/ViewParentCompat)compatibility shim static methods. This ensures interoperability with nested scrolling views on all versions of Android.

<br />

## Summary

|                                                                                                                                                                       ### Public methods                                                                                                                                                                       ||
|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract boolean` | ` `[dispatchNestedPreScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#dispatchNestedPreScroll(int, int, int[], int[], int))`(int dx, int dy, int[] consumed, int[] offsetInWindow, int type) ` Dispatch one step of a nested scroll in progress before this view consumes any portion of it. |
| ` abstract boolean` | ` `[dispatchNestedScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#dispatchNestedScroll(int, int, int, int, int[], int))`(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow, int type) ` Dispatch one step of a nested scroll in progress.            |
| ` abstract boolean` | ` `[hasNestedScrollingParent](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#hasNestedScrollingParent(int))`(int type) ` Returns true if this view has a nested scrolling parent for the given input type.                                                                                         |
| ` abstract boolean` | ` `[startNestedScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#startNestedScroll(int, int))`(int axes, int type) ` Begin a nestable scroll operation along the given axes, for the given input type.                                                                                        |
| ` abstract void`    | ` `[stopNestedScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#stopNestedScroll(int))`(int type) ` Stop a nested scroll in progress for the given input type.                                                                                                                                |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#)From interface` `[android.support.v4.view.NestedScrollingChild](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild)` ` |---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean` | ` `[dispatchNestedFling](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild#dispatchNestedFling(float, float, boolean))`(float velocityX, float velocityY, boolean consumed) ` Dispatch a fling to a nested scrolling parent.                                                           | | ` abstract boolean` | ` `[dispatchNestedPreFling](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild#dispatchNestedPreFling(float, float))`(float velocityX, float velocityY) ` Dispatch a fling to a nested scrolling parent before it is processed by this view.                                            | | ` abstract boolean` | ` `[dispatchNestedPreScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild#dispatchNestedPreScroll(int, int, int[], int[]))`(int dx, int dy, int[] consumed, int[] offsetInWindow) ` Dispatch one step of a nested scroll in progress before this view consumes any portion of it. | | ` abstract boolean` | ` `[dispatchNestedScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild#dispatchNestedScroll(int, int, int, int, int[]))`(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow) ` Dispatch one step of a nested scroll in progress.            | | ` abstract boolean` | ` `[hasNestedScrollingParent](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild#hasNestedScrollingParent())`() ` Returns true if this view has a nested scrolling parent.                                                                                                              | | ` abstract boolean` | ` `[isNestedScrollingEnabled](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild#isNestedScrollingEnabled())`() ` Returns true if nested scrolling is enabled for this view.                                                                                                            | | ` abstract void`    | ` `[setNestedScrollingEnabled](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild#setNestedScrollingEnabled(boolean))`(boolean enabled) ` Enable or disable nested scrolling for this view.                                                                                             | | ` abstract boolean` | ` `[startNestedScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild#startNestedScroll(int))`(int axes) ` Begin a nestable scroll operation along the given axes.                                                                                                                  | | ` abstract void`    | ` `[stopNestedScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild#stopNestedScroll())`() ` Stop a nested scroll in progress.                                                                                                                                                     | ||

## Public methods

### dispatchNestedPreScroll

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

```
boolean dispatchNestedPreScroll (int dx, 
                int dy, 
                int[] consumed, 
                int[] offsetInWindow, 
                int type)
```

Dispatch one step of a nested scroll in progress before this view consumes any portion of it.

Nested pre-scroll events are to nested scroll events what touch intercept is to touch.`dispatchNestedPreScroll`offers an opportunity for the parent view in a nested scrolling operation to consume some or all of the scroll operation before the child view consumes it.

<br />

<br />

|                                                                                                                               Parameters                                                                                                                               ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dx`             | `int`: Horizontal scroll distance in pixels <br />                                                                                                                                                                                                   |
| `dy`             | `int`: Vertical scroll distance in pixels <br />                                                                                                                                                                                                     |
| `consumed`       | `int`: Output. If not null, consumed\[0\] will contain the consumed component of dx and consumed\[1\] the consumed dy. <br />                                                                                                                        |
| `offsetInWindow` | `int`: Optional. If not null, on return this will contain the offset in local view coordinates of this view from before this operation to after it completes. View implementations may use this to adjust expected input coordinate tracking. <br /> |
| `type`           | `int`: the type of input which cause this scroll event <br />                                                                                                                                                                                        |

|                                    Returns                                    ||
|-----------|--------------------------------------------------------------------|
| `boolean` | true if the parent consumed some or all of the scroll delta <br /> |

**See also:**

- [dispatchNestedScroll(int, int, int, int, int[], int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#dispatchNestedScroll(int, int, int, int, int[], int))  

### dispatchNestedScroll

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

```
boolean dispatchNestedScroll (int dxConsumed, 
                int dyConsumed, 
                int dxUnconsumed, 
                int dyUnconsumed, 
                int[] offsetInWindow, 
                int type)
```

Dispatch one step of a nested scroll in progress.

Implementations of views that support nested scrolling should call this to report info about a scroll in progress to the current nested scrolling parent. If a nested scroll is not currently in progress or nested scrolling is not[enabled](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild#isNestedScrollingEnabled())for this view this method does nothing.

Compatible View implementations should also call[dispatchNestedPreScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#dispatchNestedPreScroll(int, int, int[], int[], int))before consuming a component of the scroll event themselves.

<br />

<br />

|                                                                                                                               Parameters                                                                                                                               ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dxConsumed`     | `int`: Horizontal distance in pixels consumed by this view during this scroll step <br />                                                                                                                                                            |
| `dyConsumed`     | `int`: Vertical distance in pixels consumed by this view during this scroll step <br />                                                                                                                                                              |
| `dxUnconsumed`   | `int`: Horizontal scroll distance in pixels not consumed by this view <br />                                                                                                                                                                         |
| `dyUnconsumed`   | `int`: Horizontal scroll distance in pixels not consumed by this view <br />                                                                                                                                                                         |
| `offsetInWindow` | `int`: Optional. If not null, on return this will contain the offset in local view coordinates of this view from before this operation to after it completes. View implementations may use this to adjust expected input coordinate tracking. <br /> |
| `type`           | `int`: the type of input which cause this scroll event <br />                                                                                                                                                                                        |

|                                         Returns                                          ||
|-----------|-------------------------------------------------------------------------------|
| `boolean` | true if the event was dispatched, false if it could not be dispatched. <br /> |

**See also:**

- [dispatchNestedPreScroll(int, int, int[], int[], int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#dispatchNestedPreScroll(int, int, int[], int[], int))  

### hasNestedScrollingParent

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

```
boolean hasNestedScrollingParent (int type)
```

Returns true if this view has a nested scrolling parent for the given input type.

The presence of a nested scrolling parent indicates that this view has initiated a nested scroll and it was accepted by an ancestor view further up the view hierarchy.

<br />

<br />

|                              Parameters                               ||
|--------|---------------------------------------------------------------|
| `type` | `int`: the type of input which cause this scroll event <br /> |

|                              Returns                              ||
|-----------|--------------------------------------------------------|
| `boolean` | whether this view has a nested scrolling parent <br /> |

### startNestedScroll

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

```
boolean startNestedScroll (int axes, 
                int type)
```

Begin a nestable scroll operation along the given axes, for the given input type.

A view starting a nested scroll promises to abide by the following contract:

The view will call startNestedScroll upon initiating a scroll operation. In the case of a touch scroll type this corresponds to the initial[ACTION_DOWN](https://developer.android.com/reference/android/view/MotionEvent.html#ACTION_DOWN). In the case of touch scrolling the nested scroll will be terminated automatically in the same manner as[requestDisallowInterceptTouchEvent(boolean)](https://developer.android.com/reference/android/view/ViewParent.html#requestDisallowInterceptTouchEvent(boolean)). In the event of programmatic scrolling the caller must explicitly call[stopNestedScroll(int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#stopNestedScroll(int))to indicate the end of the nested scroll.

If`startNestedScroll`returns true, a cooperative parent was found. If it returns false the caller may ignore the rest of this contract until the next scroll. Calling startNestedScroll while a nested scroll is already in progress will return true.

At each incremental step of the scroll the caller should invoke[dispatchNestedPreScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#dispatchNestedPreScroll(int, int, int[], int[], int))once it has calculated the requested scrolling delta. If it returns true the nested scrolling parent at least partially consumed the scroll and the caller should adjust the amount it scrolls by.

After applying the remainder of the scroll delta the caller should invoke[dispatchNestedScroll](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#dispatchNestedScroll(int, int, int, int, int[], int)), passing both the delta consumed and the delta unconsumed. A nested scrolling parent may treat these values differently. See[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)).

<br />

<br />

|                                                                                                                                                     Parameters                                                                                                                                                      ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `axes` | `int`: Flags consisting of a combination of[SCROLL_AXIS_HORIZONTAL](https://developer.android.com/reference/android/support/v4/view/ViewCompat#SCROLL_AXIS_HORIZONTAL)and/or[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 a cooperative parent was found and nested scrolling has been enabled for the current gesture. <br /> |

**See also:**

- [stopNestedScroll(int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#stopNestedScroll(int))
- [dispatchNestedPreScroll(int, int, int[], int[], int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#dispatchNestedPreScroll(int, int, int[], int[], int))
- [dispatchNestedScroll(int, int, int, int, int[], int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#dispatchNestedScroll(int, int, int, int, int[], int))  

### stopNestedScroll

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

```
void stopNestedScroll (int type)
```

Stop a nested scroll in progress for the given input type.

Calling this method when a nested scroll is not currently in progress is harmless.

<br />

<br />

|                              Parameters                               ||
|--------|---------------------------------------------------------------|
| `type` | `int`: the type of input which cause this scroll event <br /> |

**See also:**

- [startNestedScroll(int, int)](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2#startNestedScroll(int, int))  
-

  ## Annotations

  - [ViewPager.DecorView](https://developer.android.com/reference/android/support/v4/view/ViewPager.DecorView)
-

  ## Interfaces

  - [ActionProvider.VisibilityListener](https://developer.android.com/reference/android/support/v4/view/ActionProvider.VisibilityListener)
  - [AsyncLayoutInflater.OnInflateFinishedListener](https://developer.android.com/reference/android/support/v4/view/AsyncLayoutInflater.OnInflateFinishedListener)
  - [LayoutInflaterFactory](https://developer.android.com/reference/android/support/v4/view/LayoutInflaterFactory)
  - [MenuItemCompat.OnActionExpandListener](https://developer.android.com/reference/android/support/v4/view/MenuItemCompat.OnActionExpandListener)
  - [NestedScrollingChild](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild)
  - [NestedScrollingChild2](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChild2)
  - [NestedScrollingParent](https://developer.android.com/reference/android/support/v4/view/NestedScrollingParent)
  - [NestedScrollingParent2](https://developer.android.com/reference/android/support/v4/view/NestedScrollingParent2)
  - [OnApplyWindowInsetsListener](https://developer.android.com/reference/android/support/v4/view/OnApplyWindowInsetsListener)
  - [ScrollingView](https://developer.android.com/reference/android/support/v4/view/ScrollingView)
  - [TintableBackgroundView](https://developer.android.com/reference/android/support/v4/view/TintableBackgroundView)
  - [ViewPager.OnAdapterChangeListener](https://developer.android.com/reference/android/support/v4/view/ViewPager.OnAdapterChangeListener)
  - [ViewPager.OnPageChangeListener](https://developer.android.com/reference/android/support/v4/view/ViewPager.OnPageChangeListener)
  - [ViewPager.PageTransformer](https://developer.android.com/reference/android/support/v4/view/ViewPager.PageTransformer)
  - [ViewPropertyAnimatorListener](https://developer.android.com/reference/android/support/v4/view/ViewPropertyAnimatorListener)
  - [ViewPropertyAnimatorUpdateListener](https://developer.android.com/reference/android/support/v4/view/ViewPropertyAnimatorUpdateListener)
-

  ## Classes

  - [AbsSavedState](https://developer.android.com/reference/android/support/v4/view/AbsSavedState)
  - [AccessibilityDelegateCompat](https://developer.android.com/reference/android/support/v4/view/AccessibilityDelegateCompat)
  - [ActionProvider](https://developer.android.com/reference/android/support/v4/view/ActionProvider)
  - [AsyncLayoutInflater](https://developer.android.com/reference/android/support/v4/view/AsyncLayoutInflater)
  - [GestureDetectorCompat](https://developer.android.com/reference/android/support/v4/view/GestureDetectorCompat)
  - [GravityCompat](https://developer.android.com/reference/android/support/v4/view/GravityCompat)
  - [InputDeviceCompat](https://developer.android.com/reference/android/support/v4/view/InputDeviceCompat)
  - [LayoutInflaterCompat](https://developer.android.com/reference/android/support/v4/view/LayoutInflaterCompat)
  - [MarginLayoutParamsCompat](https://developer.android.com/reference/android/support/v4/view/MarginLayoutParamsCompat)
  - [MenuCompat](https://developer.android.com/reference/android/support/v4/view/MenuCompat)
  - [MenuItemCompat](https://developer.android.com/reference/android/support/v4/view/MenuItemCompat)
  - [MotionEventCompat](https://developer.android.com/reference/android/support/v4/view/MotionEventCompat)
  - [NestedScrollingChildHelper](https://developer.android.com/reference/android/support/v4/view/NestedScrollingChildHelper)
  - [NestedScrollingParentHelper](https://developer.android.com/reference/android/support/v4/view/NestedScrollingParentHelper)
  - [PagerAdapter](https://developer.android.com/reference/android/support/v4/view/PagerAdapter)
  - [PagerTabStrip](https://developer.android.com/reference/android/support/v4/view/PagerTabStrip)
  - [PagerTitleStrip](https://developer.android.com/reference/android/support/v4/view/PagerTitleStrip)
  - [PointerIconCompat](https://developer.android.com/reference/android/support/v4/view/PointerIconCompat)
  - [ScaleGestureDetectorCompat](https://developer.android.com/reference/android/support/v4/view/ScaleGestureDetectorCompat)
  - [VelocityTrackerCompat](https://developer.android.com/reference/android/support/v4/view/VelocityTrackerCompat)
  - [ViewCompat](https://developer.android.com/reference/android/support/v4/view/ViewCompat)
  - [ViewConfigurationCompat](https://developer.android.com/reference/android/support/v4/view/ViewConfigurationCompat)
  - [ViewGroupCompat](https://developer.android.com/reference/android/support/v4/view/ViewGroupCompat)
  - [ViewPager](https://developer.android.com/reference/android/support/v4/view/ViewPager)
  - [ViewPager.LayoutParams](https://developer.android.com/reference/android/support/v4/view/ViewPager.LayoutParams)
  - [ViewPager.SavedState](https://developer.android.com/reference/android/support/v4/view/ViewPager.SavedState)
  - [ViewPager.SimpleOnPageChangeListener](https://developer.android.com/reference/android/support/v4/view/ViewPager.SimpleOnPageChangeListener)
  - [ViewParentCompat](https://developer.android.com/reference/android/support/v4/view/ViewParentCompat)
  - [ViewPropertyAnimatorCompat](https://developer.android.com/reference/android/support/v4/view/ViewPropertyAnimatorCompat)
  - [ViewPropertyAnimatorListenerAdapter](https://developer.android.com/reference/android/support/v4/view/ViewPropertyAnimatorListenerAdapter)
  - [WindowCompat](https://developer.android.com/reference/android/support/v4/view/WindowCompat)
  - [WindowInsetsCompat](https://developer.android.com/reference/android/support/v4/view/WindowInsetsCompat)