NestedScrollingParent2
public interface NestedScrollingParent2 extends NestedScrollingParent
CoordinatorLayout |
CoordinatorLayout is a super-powered |
NestedScrollingParent3 |
This interface should be implemented by |
SwipeRefreshLayout |
The SwipeRefreshLayout should be used whenever the user can refresh the contents of a view via a vertical swipe gesture. |
CoordinatorLayout |
CoordinatorLayout is a super-powered |
MotionLayout |
A subclass of ConstraintLayout that supports animating between various states Added in 2.0 |
NestedScrollView |
NestedScrollView is just like |
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 methods |
|
|---|---|
abstract void |
onNestedPreScroll(React to a nested scroll in progress before the target view consumes a portion of the scroll. |
abstract void |
onNestedScroll(React to a nested scroll in progress. |
abstract void |
onNestedScrollAccepted(React to the successful claiming of a nested scroll operation. |
abstract boolean |
onStartNestedScroll(React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate. |
abstract void |
onStopNestedScroll(@NonNull View target, int type)React to a nested scroll operation ending. |
Inherited methods |
||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public methods
onNestedPreScroll
abstract void onNestedPreScroll(
@NonNull View target,
int dx,
int dy,
@NonNull int[] consumed,
int type
)
React to a nested scroll in progress before the target view consumes a portion of the scroll.
When working with nested scrolling often the parent view may want an opportunity to consume the scroll before the nested scrolling child does. An example of this is a drawer that contains a scrollable list. The user will want to be able to scroll the list fully into view before the list itself begins scrolling.
onNestedPreScroll is called when a nested scrolling child invokes dispatchNestedPreScroll. The implementation should report how any pixels of the scroll reported by dx, dy were consumed in the consumed array. Index 0 corresponds to dx and index 1 corresponds to dy. This parameter will never be null. Initial values for consumed[0] and consumed[1] will always be 0.
| Parameters | |
|---|---|
@NonNull View target |
View that initiated the nested scroll |
int dx |
Horizontal scroll distance in pixels |
int dy |
Vertical scroll distance in pixels |
@NonNull int[] consumed |
Output. The horizontal and vertical scroll distance consumed by this parent |
int type |
the type of input which cause this scroll event |
onNestedScroll
abstract void onNestedScroll(
@NonNull View target,
int dxConsumed,
int dyConsumed,
int dxUnconsumed,
int dyUnconsumed,
int type
)
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.
| Parameters | |
|---|---|
@NonNull View target |
The descendent view controlling the nested scroll |
int dxConsumed |
Horizontal scroll distance in pixels already consumed by target |
int dyConsumed |
Vertical scroll distance in pixels already consumed by target |
int dxUnconsumed |
Horizontal scroll distance in pixels not consumed by target |
int dyUnconsumed |
Vertical scroll distance in pixels not consumed by target |
int type |
the type of input which cause this scroll event |
onNestedScrollAccepted
abstract void onNestedScrollAccepted(
@NonNull View child,
@NonNull View target,
int axes,
int type
)
React to the successful claiming of a nested scroll operation.
This method will be called after onStartNestedScroll returns true. It offers an opportunity for the view and its superclasses to perform initial configuration for the nested scroll. Implementations of this method should always call their superclass's implementation of this method if one is present.
| Parameters | |
|---|---|
@NonNull View child |
Direct child of this ViewParent containing target |
@NonNull View target |
View that initiated the nested scroll |
int axes |
Flags consisting of |
int type |
the type of input which cause this scroll event |
| See also | |
|---|---|
onStartNestedScroll |
|
onStopNestedScroll |
onStartNestedScroll
abstract boolean onStartNestedScroll(
@NonNull View child,
@NonNull View target,
int axes,
int type
)
React to a descendant view initiating a nestable scroll operation, claiming the nested scroll operation if appropriate.
This method will be called in response to a descendant view invoking startNestedScroll. Each parent up the view hierarchy will be given an opportunity to respond and claim the nested scrolling operation by returning true.
This method may be overridden by ViewParent implementations to indicate when the view is willing to support a nested scrolling operation that is about to begin. If it returns true, this ViewParent will become the target view's nested scrolling parent for the duration of the scroll operation in progress. When the nested scroll is finished this ViewParent will receive a call to onStopNestedScroll.
| Parameters | |
|---|---|
@NonNull View child |
Direct child of this ViewParent containing target |
@NonNull View target |
View that initiated the nested scroll |
int axes |
Flags consisting of |
int type |
the type of input which cause this scroll event |
| Returns | |
|---|---|
boolean |
true if this ViewParent accepts the nested scroll operation |
onStopNestedScroll
abstract void onStopNestedScroll(@NonNull View target, int type)
React to a nested scroll operation ending.
Perform cleanup after a nested scrolling operation. This method will be called when a nested scroll stops, for example when a nested touch scroll ends with a ACTION_UP or ACTION_CANCEL event. Implementations of this method should always call their superclass's implementation of this method if one is present.