NestedScrollingChild2
interface NestedScrollingChild2 : NestedScrollingChild
NestedScrollingChild3 |
This interface should be implemented by |
RecyclerView |
A flexible view for providing a limited window into a large data set. |
SwipeRefreshLayout |
The SwipeRefreshLayout should be used whenever the user can refresh the contents of a view via a vertical swipe gesture. |
BaseGridView |
An abstract base class for vertically and horizontally scrolling lists. |
HorizontalGridView |
A |
NestedScrollView |
NestedScrollView is just like |
RecyclerView |
A flexible view for providing a limited window into a large data set. |
SwipeRefreshLayout |
The SwipeRefreshLayout should be used whenever the user can refresh the contents of a view via a vertical swipe gesture. |
VerticalGridView |
A |
WearableRecyclerView |
Wearable specific implementation of the |
This interface should be implemented by View subclasses that wish to support dispatching nested scrolling operations to a cooperating parent ViewGroup.
Classes implementing this interface should create a final instance of a 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, ViewGroupCompat or ViewParentCompat compatibility shim static methods. This ensures interoperability with nested scrolling views on all versions of Android.
Summary
Public functions |
|
|---|---|
Boolean |
dispatchNestedPreScroll(Dispatch one step of a nested scroll in progress before this view consumes any portion of it. |
Boolean |
dispatchNestedScroll(Dispatch one step of a nested scroll in progress. |
Boolean |
hasNestedScrollingParent(type: Int)Returns true if this view has a nested scrolling parent for the given input type. |
Boolean |
startNestedScroll(axes: Int, type: Int)Begin a nestable scroll operation along the given axes, for the given input type. |
Unit |
stopNestedScroll(type: Int)Stop a nested scroll in progress for the given input type. |
Inherited functions |
||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public functions
dispatchNestedPreScroll
fun dispatchNestedPreScroll(
dx: Int,
dy: Int,
consumed: IntArray?,
offsetInWindow: IntArray?,
type: Int
): Boolean
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.
| Parameters | |
|---|---|
dx: Int |
Horizontal scroll distance in pixels |
dy: Int |
Vertical scroll distance in pixels |
consumed: IntArray? |
Output. If not null, consumed[0] will contain the consumed component of dx and consumed[1] the consumed dy. |
offsetInWindow: IntArray? |
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. |
type: Int |
the type of input which cause this scroll event |
| Returns | |
|---|---|
Boolean |
true if the parent consumed some or all of the scroll delta |
| See also | |
|---|---|
dispatchNestedScroll |
dispatchNestedScroll
fun dispatchNestedScroll(
dxConsumed: Int,
dyConsumed: Int,
dxUnconsumed: Int,
dyUnconsumed: Int,
offsetInWindow: IntArray?,
type: Int
): Boolean
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 for this view this method does nothing.
Compatible View implementations should also call dispatchNestedPreScroll before consuming a component of the scroll event themselves.
| Parameters | |
|---|---|
dxConsumed: Int |
Horizontal distance in pixels consumed by this view during this scroll step |
dyConsumed: Int |
Vertical distance in pixels consumed by this view during this scroll step |
dxUnconsumed: Int |
Horizontal scroll distance in pixels not consumed by this view |
dyUnconsumed: Int |
Horizontal scroll distance in pixels not consumed by this view |
offsetInWindow: IntArray? |
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. |
type: Int |
the type of input which cause this scroll event |
| Returns | |
|---|---|
Boolean |
true if the event was dispatched, false if it could not be dispatched. |
| See also | |
|---|---|
dispatchNestedPreScroll |
hasNestedScrollingParent
fun hasNestedScrollingParent(type: Int): Boolean
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.
| Parameters | |
|---|---|
type: Int |
the type of input which cause this scroll event |
| Returns | |
|---|---|
Boolean |
whether this view has a nested scrolling parent |
startNestedScroll
fun startNestedScroll(axes: Int, type: Int): Boolean
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. In the case of touch scrolling the nested scroll will be terminated automatically in the same manner as requestDisallowInterceptTouchEvent. In the event of programmatic scrolling the caller must explicitly call stopNestedScroll 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 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, passing both the delta consumed and the delta unconsumed. A nested scrolling parent may treat these values differently. See onNestedScroll.
| Parameters | |
|---|---|
axes: Int |
Flags consisting of a combination of |
type: Int |
the type of input which cause this scroll event |
| Returns | |
|---|---|
Boolean |
true if a cooperative parent was found and nested scrolling has been enabled for the current gesture. |
stopNestedScroll
fun stopNestedScroll(type: Int): Unit
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.
| Parameters | |
|---|---|
type: Int |
the type of input which cause this scroll event |
| See also | |
|---|---|
startNestedScroll |