Package 

Class NestedScrollingChildHelper


  • 
    public 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 ViewCompat, androidx.core.view.ViewGroupCompat or ViewParentCompat compatibility shim static methods. This ensures interoperability with nested scrolling views on Android 5.0 Lollipop and newer.

    • Method Summary

      Modifier and Type Method Description
      void setNestedScrollingEnabled(boolean enabled) Enable nested scrolling.
      boolean isNestedScrollingEnabled() Check if nested scrolling is enabled for this view.
      boolean hasNestedScrollingParent() Check if this view has a nested scrolling parent view currently receiving events fora nested scroll in progress with the type of touch.
      boolean hasNestedScrollingParent(int type) Check if this view has a nested scrolling parent view currently receiving events fora nested scroll in progress with the given type.
      boolean startNestedScroll(int axes) Start a new nested scroll for this view.
      boolean startNestedScroll(int axes, int type) Start a new nested scroll for this view.
      void stopNestedScroll() Stop a nested scroll in progress.
      void stopNestedScroll(int type) Stop a nested scroll in progress.
      boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @Nullable() Array<int> offsetInWindow) Dispatch one step of a nested scrolling operation to the current nested scrolling parent.
      boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @Nullable() Array<int> offsetInWindow, int type) Dispatch one step of a nested scrolling operation to the current nested scrolling parent.
      void dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @Nullable() Array<int> offsetInWindow, int type, @Nullable() Array<int> consumed) Dispatch one step of a nested scrolling operation to the current nested scrolling parent.
      boolean dispatchNestedPreScroll(int dx, int dy, @Nullable() Array<int> consumed, @Nullable() Array<int> offsetInWindow) Dispatch one step of a nested pre-scrolling operation to the current nested scrolling parent.
      boolean dispatchNestedPreScroll(int dx, int dy, @Nullable() Array<int> consumed, @Nullable() Array<int> offsetInWindow, int type) Dispatch one step of a nested pre-scrolling operation to the current nested scrolling parent.
      boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed) Dispatch a nested fling operation to the current nested scrolling parent.
      boolean dispatchNestedPreFling(float velocityX, float velocityY) Dispatch a nested pre-fling operation to the current nested scrolling parent.
      void onDetachedFromWindow() View subclasses should always call this method on theirNestedScrollingChildHelper when detached from a window.
      void onStopNestedScroll(@NonNull() View child) Called when a nested scrolling child stops its current nested scroll operation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NestedScrollingChildHelper

        NestedScrollingChildHelper(View view)
        Construct a new helper for a given view.
    • Method Detail

      • setNestedScrollingEnabled

         void setNestedScrollingEnabled(boolean enabled)

        Enable nested scrolling.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

        Parameters:
        enabled - true to enable nested scrolling dispatch from this view, false otherwise
      • isNestedScrollingEnabled

         boolean isNestedScrollingEnabled()

        Check if nested scrolling is enabled for this view.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

      • hasNestedScrollingParent

         boolean hasNestedScrollingParent()

        Check if this view has a nested scrolling parent view currently receiving events fora nested scroll in progress with the type of touch.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

      • hasNestedScrollingParent

         boolean hasNestedScrollingParent(int type)

        Check if this view has a nested scrolling parent view currently receiving events fora nested scroll in progress with the given type.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

      • startNestedScroll

         boolean startNestedScroll(int axes)

        Start a new nested scroll for this view.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

        Parameters:
        axes - Supported nested scroll axes.
      • startNestedScroll

         boolean startNestedScroll(int axes, int type)

        Start a new nested scroll for this view.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild2 interface method with the samesignature to implement the standard policy.

        Parameters:
        axes - Supported nested scroll axes.
      • stopNestedScroll

         void stopNestedScroll()

        Stop a nested scroll in progress.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

      • stopNestedScroll

         void stopNestedScroll(int type)

        Stop a nested scroll in progress.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild2 interface method with the samesignature to implement the standard policy.

      • dispatchNestedScroll

         boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @Nullable() Array<int> offsetInWindow)

        Dispatch one step of a nested scrolling operation to the current nested scrolling parent.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

      • dispatchNestedScroll

         boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @Nullable() Array<int> offsetInWindow, int type)

        Dispatch one step of a nested scrolling operation to the current nested scrolling parent.

        This is a delegate method. Call it from your NestedScrollingChild2 interfacemethod with the same signature to implement the standard policy.

      • dispatchNestedScroll

         void dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @Nullable() Array<int> offsetInWindow, int type, @Nullable() Array<int> consumed)

        Dispatch one step of a nested scrolling operation to the current nested scrolling parent.

        This is a delegate method. Call it from your NestedScrollingChild3 interfacemethod with the same signature to implement the standard policy.

      • dispatchNestedPreScroll

         boolean dispatchNestedPreScroll(int dx, int dy, @Nullable() Array<int> consumed, @Nullable() Array<int> offsetInWindow)

        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 subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

      • dispatchNestedPreScroll

         boolean dispatchNestedPreScroll(int dx, int dy, @Nullable() Array<int> consumed, @Nullable() Array<int> offsetInWindow, int type)

        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 subclassmethod/NestedScrollingChild2 interface method with the samesignature to implement the standard policy.

      • dispatchNestedFling

         boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed)

        Dispatch a nested fling operation to the current nested scrolling parent.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

      • dispatchNestedPreFling

         boolean dispatchNestedPreFling(float velocityX, float velocityY)

        Dispatch a nested pre-fling operation to the current nested scrolling parent.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

      • onDetachedFromWindow

         void onDetachedFromWindow()

        View subclasses should always call this method on theirNestedScrollingChildHelper when detached from a window.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

      • onStopNestedScroll

         void onStopNestedScroll(@NonNull() View child)

        Called when a nested scrolling child stops its current nested scroll operation.

        This is a delegate method. Call it from your View subclassmethod/NestedScrollingChild interface method with the samesignature to implement the standard policy.

        Parameters:
        child - Child view stopping its nested scroll.