NestedScrollingParent3

Added in 1.1.0

interface NestedScrollingParent3 : NestedScrollingParent2

Known direct subclasses
CoordinatorLayout

CoordinatorLayout is a super-powered FrameLayout.

MotionLayout

A subclass of ConstraintLayout that supports animating between various states Added in 2.0

NestedScrollView

NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android.

SwipeRefreshLayout

The SwipeRefreshLayout should be used whenever the user can refresh the contents of a view via a vertical swipe gesture.


This interface should be implemented by ViewGroup subclasses that wish to support scrolling operations delegated by a nested child view.

Classes implementing this interface should create a final instance of a NestedScrollingParentHelper as a field and delegate any View or ViewGroup methods to the NestedScrollingParentHelper methods of the same signature.

Views invoking nested scrolling functionality should always do so from the relevant ViewCompat, ViewGroupCompat or ViewParentCompat compatibility shim static methods. This ensures interoperability with nested scrolling views on all versions of Android.

Summary

Public functions

Unit
onNestedScroll(
    target: View,
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int,
    type: Int,
    consumed: IntArray
)

React to a nested scroll in progress.

Inherited functions

From androidx.core.view.NestedScrollingParent
Int

Return the current axes of nested scrolling for this NestedScrollingParent.

Boolean
onNestedFling(
    target: View,
    velocityX: Float,
    velocityY: Float,
    consumed: Boolean
)

Request a fling from a nested scroll.

Boolean
onNestedPreFling(target: View, velocityX: Float, velocityY: Float)

React to a nested fling before the target view consumes it.

Unit
onNestedPreScroll(target: View, dx: Int, dy: Int, consumed: IntArray)

React to a nested scroll in progress before the target view consumes a portion of the scroll.

Unit
onNestedScroll(
    target: View,
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int
)

React to a nested scroll in progress.

Unit
onNestedScrollAccepted(child: View, target: View, axes: Int)

React to the successful claiming of a nested scroll operation.

Boolean
onStartNestedScroll(child: View, target: View, axes: Int)

React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.

Unit

React to a nested scroll operation ending.

From androidx.core.view.NestedScrollingParent2
Unit
onNestedPreScroll(
    target: View,
    dx: Int,
    dy: Int,
    consumed: IntArray,
    type: Int
)

React to a nested scroll in progress before the target view consumes a portion of the scroll.

Unit
onNestedScroll(
    target: View,
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int,
    type: Int
)

React to a nested scroll in progress.

Unit
onNestedScrollAccepted(child: View, target: View, axes: Int, type: Int)

React to the successful claiming of a nested scroll operation.

Boolean
onStartNestedScroll(child: View, target: View, axes: Int, type: Int)

React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.

Unit
onStopNestedScroll(target: View, type: Int)

React to a nested scroll operation ending.

Public functions

onNestedScroll

Added in 1.1.0
fun onNestedScroll(
    target: View,
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int,
    type: Int,
    consumed: IntArray
): Unit

React to a nested scroll in progress.

This method will be called when the ViewParent's current nested scrolling child view dispatches a nested scroll event. To receive calls to this method the ViewParent must have previously returned true for a call to onStartNestedScroll.

Both the consumed and unconsumed portions of the scroll distance are reported to the ViewParent. An implementation may choose to use the consumed portion to match or chase scroll position of multiple child elements, for example. The unconsumed portion may be used to allow continuous dragging of multiple scrolling or draggable elements, such as scrolling a list within a vertical drawer where the drawer begins dragging once the edge of inner scrolling content is reached.

This method is called when a nested scrolling child invokes dispatchNestedScroll} or one of methods it overloads.

An implementation must report how many pixels of the the x and y scroll distances were consumed by this nested scrolling parent by adding the consumed distances to the consumed parameter. If this View also implements NestedScrollingChild3, consumed should also be passed up to it's nested scrolling parent so that the parent may also add any scroll distance it consumes. Index 0 corresponds to dx and index 1 corresponds to dy.

Parameters
target: View

The descendant view controlling the nested scroll

dxConsumed: Int

Horizontal scroll distance in pixels already consumed by target

dyConsumed: Int

Vertical scroll distance in pixels already consumed by target

dxUnconsumed: Int

Horizontal scroll distance in pixels not consumed by target

dyUnconsumed: Int

Vertical scroll distance in pixels not consumed by target

type: Int

the type of input which cause this scroll event

consumed: IntArray

Output. Upon this method returning, will contain the scroll distances consumed by this nested scrolling parent and the scroll distances consumed by any other parent up the view hierarchy