NestedScrollingChildHelper
class NestedScrollingChildHelper
Helper class for implementing nested scrolling child views compatible with Android platform versions earlier than Android 5.0 Lollipop (API 21).
View subclasses should instantiate a final instance of this class as a field at construction. For each View method that has a matching method signature in this class, delegate the operation to the helper instance in an overridden method implementation. This implements the standard framework policy for nested scrolling.
Views invoking nested scrolling functionality should always do so from the relevant androidx.core.view.ViewCompat, androidx.core.view.ViewGroupCompat or androidx.core.view.ViewParentCompat compatibility shim static methods. This ensures interoperability with nested scrolling views on Android 5.0 Lollipop and newer.
Summary
Public constructors |
|---|
NestedScrollingChildHelper(view: View)Construct a new helper for a given view. |
Public functions |
|
|---|---|
Boolean |
dispatchNestedFling(velocityX: Float, velocityY: Float, consumed: Boolean)Dispatch a nested fling operation to the current nested scrolling parent. |
Boolean |
dispatchNestedPreFling(velocityX: Float, velocityY: Float)Dispatch a nested pre-fling operation to the current nested scrolling parent. |
Boolean |
dispatchNestedPreScroll(Dispatch one step of a nested pre-scrolling operation to the current nested scrolling parent. |
Boolean |
dispatchNestedPreScroll(Dispatch one step of a nested pre-scrolling operation to the current nested scrolling parent. |
Boolean |
dispatchNestedScroll(Dispatch one step of a nested scrolling operation to the current nested scrolling parent. |
Boolean |
dispatchNestedScroll(Dispatch one step of a nested scrolling operation to the current nested scrolling parent. |
Unit |
dispatchNestedScroll(Dispatch one step of a nested scrolling operation to the current nested scrolling parent. |
Boolean |
Check if this view has a nested scrolling parent view currently receiving events for a nested scroll in progress with the type of touch. |
Boolean |
hasNestedScrollingParent(type: Int)Check if this view has a nested scrolling parent view currently receiving events for a nested scroll in progress with the given type. |
Boolean |
Check if nested scrolling is enabled for this view. |
Unit |
View subclasses should always call this method on their |
Unit |
onStopNestedScroll(child: View)Called when a nested scrolling child stops its current nested scroll operation. |
Unit |
setNestedScrollingEnabled(enabled: Boolean)Enable nested scrolling. |
Boolean |
startNestedScroll(axes: Int)Start a new nested scroll for this view. |
Boolean |
startNestedScroll(axes: Int, type: Int)Start a new nested scroll for this view. |
Unit |
Stop a nested scroll in progress. |
Unit |
stopNestedScroll(type: Int)Stop a nested scroll in progress. |
Public constructors
NestedScrollingChildHelper
NestedScrollingChildHelper(view: View)
Construct a new helper for a given view.
Public functions
dispatchNestedFling
fun dispatchNestedFling(velocityX: Float, velocityY: Float, consumed: Boolean): Boolean
Dispatch a nested fling operation to the current nested scrolling parent.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
| Returns | |
|---|---|
Boolean |
true if the parent consumed the nested fling |
dispatchNestedPreFling
fun dispatchNestedPreFling(velocityX: Float, velocityY: Float): Boolean
Dispatch a nested pre-fling operation to the current nested scrolling parent.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
| Returns | |
|---|---|
Boolean |
true if the parent consumed the nested fling |
dispatchNestedPreScroll
fun dispatchNestedPreScroll(
dx: Int,
dy: Int,
consumed: IntArray?,
offsetInWindow: IntArray?
): Boolean
Dispatch one step of a nested pre-scrolling operation to the current nested scrolling parent.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
| Returns | |
|---|---|
Boolean |
true if the parent consumed any of the nested scroll |
dispatchNestedPreScroll
fun dispatchNestedPreScroll(
dx: Int,
dy: Int,
consumed: IntArray?,
offsetInWindow: IntArray?,
type: Int
): Boolean
Dispatch one step of a nested pre-scrolling operation to the current nested scrolling parent.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild2 interface method with the same signature to implement the standard policy.
| Returns | |
|---|---|
Boolean |
true if the parent consumed any of the nested scroll |
dispatchNestedScroll
fun dispatchNestedScroll(
dxConsumed: Int,
dyConsumed: Int,
dxUnconsumed: Int,
dyUnconsumed: Int,
offsetInWindow: IntArray?
): Boolean
Dispatch one step of a nested scrolling operation to the current nested scrolling parent.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
| Returns | |
|---|---|
Boolean |
|
dispatchNestedScroll
fun dispatchNestedScroll(
dxConsumed: Int,
dyConsumed: Int,
dxUnconsumed: Int,
dyUnconsumed: Int,
offsetInWindow: IntArray?,
type: Int
): Boolean
Dispatch one step of a nested scrolling operation to the current nested scrolling parent.
This is a delegate method. Call it from your NestedScrollingChild2 interface method with the same signature to implement the standard policy.
| Returns | |
|---|---|
Boolean |
|
dispatchNestedScroll
fun dispatchNestedScroll(
dxConsumed: Int,
dyConsumed: Int,
dxUnconsumed: Int,
dyUnconsumed: Int,
offsetInWindow: IntArray?,
type: Int,
consumed: IntArray?
): Unit
Dispatch one step of a nested scrolling operation to the current nested scrolling parent.
This is a delegate method. Call it from your NestedScrollingChild3 interface method with the same signature to implement the standard policy.
hasNestedScrollingParent
fun hasNestedScrollingParent(): Boolean
Check if this view has a nested scrolling parent view currently receiving events for a nested scroll in progress with the type of touch.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
| Returns | |
|---|---|
Boolean |
true if this view has a nested scrolling parent, false otherwise |
hasNestedScrollingParent
fun hasNestedScrollingParent(type: Int): Boolean
Check if this view has a nested scrolling parent view currently receiving events for a nested scroll in progress with the given type.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
| Returns | |
|---|---|
Boolean |
true if this view has a nested scrolling parent, false otherwise |
isNestedScrollingEnabled
fun isNestedScrollingEnabled(): Boolean
Check if nested scrolling is enabled for this view.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
| Returns | |
|---|---|
Boolean |
true if nested scrolling is enabled for this view |
onDetachedFromWindow
fun onDetachedFromWindow(): Unit
View subclasses should always call this method on their NestedScrollingChildHelper when detached from a window.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
onStopNestedScroll
fun onStopNestedScroll(child: View): Unit
Called when a nested scrolling child stops its current nested scroll operation.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
| Parameters | |
|---|---|
child: View |
Child view stopping its nested scroll. This may not be a direct child view. |
setNestedScrollingEnabled
fun setNestedScrollingEnabled(enabled: Boolean): Unit
Enable nested scrolling.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
| Parameters | |
|---|---|
enabled: Boolean |
true to enable nested scrolling dispatch from this view, false otherwise |
startNestedScroll
fun startNestedScroll(axes: Int): Boolean
Start a new nested scroll for this view.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
| Parameters | |
|---|---|
axes: Int |
Supported nested scroll axes. See |
| Returns | |
|---|---|
Boolean |
true if a cooperating parent view was found and nested scrolling started successfully |
startNestedScroll
fun startNestedScroll(axes: Int, type: Int): Boolean
Start a new nested scroll for this view.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild2 interface method with the same signature to implement the standard policy.
| Parameters | |
|---|---|
axes: Int |
Supported nested scroll axes. See |
type: Int |
type of the scroll. |
| Returns | |
|---|---|
Boolean |
true if a cooperating parent view was found and nested scrolling started successfully |
stopNestedScroll
fun stopNestedScroll(): Unit
Stop a nested scroll in progress.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild interface method with the same signature to implement the standard policy.
stopNestedScroll
fun stopNestedScroll(type: Int): Unit
Stop a nested scroll in progress.
This is a delegate method. Call it from your View subclass method/androidx.core.view.NestedScrollingChild2 interface method with the same signature to implement the standard policy.