Package 

Class RecyclerView

  • All Implemented Interfaces:
    android.graphics.drawable.Drawable.Callback , android.view.KeyEvent.Callback , android.view.ViewManager , android.view.ViewParent , android.view.accessibility.AccessibilityEventSource , tds.androidx.core.view.NestedScrollingChild , tds.androidx.core.view.NestedScrollingChild2 , tds.androidx.core.view.NestedScrollingChild3 , tds.androidx.core.view.ScrollingView

    
    public class RecyclerView
    extends ViewGroup implements ScrollingView, NestedScrollingChild2, NestedScrollingChild3
                        

    A flexible view for providing a limited window into a large data set.

    Glossary of terms:
    • Adapter: A subclass of Adapter responsible for providing views that represent items in a data set.
    • Position: The position of a data item within an Adapter.
    • Index: The index of an attached child view as used in a call to getChildAt. Contrast with Position.
    • Binding: The process of preparing a child view to display data corresponding to a position within the adapter.
    • Recycle (view): A view previously used to display data for a specific adapter position may be placed in a cache for later reuse to display the same type of data again later. This can drastically improve performance by skipping initial layout inflation or construction.
    • Scrap (view): A child view that has entered into a temporarily detached state during layout. Scrap views may be reused without becoming fully detached from the parent RecyclerView, either unmodified if no rebinding is required or modified by the adapter if the view was considered dirty.
    • Dirty (view): A child view that must be rebound by the adapter before being displayed.
    Positions in RecyclerView:

    RecyclerView introduces an additional level of abstraction between the Adapter and LayoutManager to be able to detect data set changes in batches during a layout calculation. This saves LayoutManager from tracking adapter changes to calculate animations. It also helps with performance because all view bindings happen at the same time and unnecessary bindings are avoided.

    For this reason, there are two types of position related methods in RecyclerView:

    • layout position: Position of an item in the latest layout calculation. This is the position from the LayoutManager's perspective.
    • adapter position: Position of an item in the adapter. This is the position from the Adapter's perspective.

    These two positions are the same except the time between dispatching adapter.notify* events and calculating the updated layout.

    Methods that return or receive *LayoutPosition* use position as of the latest layout calculation (e.g. getLayoutPosition, findViewHolderForLayoutPosition). These positions include all changes until the last layout calculation. You can rely on these positions to be consistent with what user is currently seeing on the screen. For example, if you have a list of items on the screen and user asks for the 5th element, you should use these methods as they'll match what user is seeing.

    The other set of position related methods are in the form of *AdapterPosition*. (e.g. getAbsoluteAdapterPosition, getBindingAdapterPosition, findViewHolderForAdapterPosition) You should use these methods when you need to work with up-to-date adapter positions even if they may not have been reflected to layout yet. For example, if you want to access the item in the adapter on a ViewHolder click, you should use getBindingAdapterPosition. Beware that these methods may not be able to calculate adapter positions if notifyDataSetChanged has been called and new layout has not yet been calculated. For this reasons, you should carefully handle NO_POSITION or null results from these methods.

    When writing a LayoutManager you almost always want to use layout positions whereas when writing an Adapter, you probably want to use adapter positions.

    Presenting Dynamic DataTo display updatable data in a RecyclerView, your adapter needs to signal inserts, moves, and deletions to RecyclerView. You can build this yourself by manually calling {@code adapter.notify*} methods when content changes, or you can use one of the easier solutions RecyclerView provides: List diffing with DiffUtilIf your RecyclerView is displaying a list that is re-fetched from scratch for each update (e.g. from the network, or from a database), DiffUtil can calculate the difference between versions of the list. {@code DiffUtil} takes both lists as input and computes the difference, which can be passed to RecyclerView to trigger minimal animations and updates to keep your UI performant, and animations meaningful. This approach requires that each list is represented in memory with immutable content, and relies on receiving updates as new instances of lists. This approach is also ideal if your UI layer doesn't implement sorting, it just presents the data in the order it's given.

    The best part of this approach is that it extends to any arbitrary changes - item updates, moves, addition and removal can all be computed and handled the same way. Though you do have to keep two copies of the list in memory while diffing, and must avoid mutating them, it's possible to share unmodified elements between list versions.

    There are three primary ways to do this for RecyclerView. We recommend you start with ListAdapter, the higher-level API that builds in List diffing on a background thread, with minimal code. AsyncListDiffer also provides this behavior, but without defining an Adapter to subclass. If you want more control, DiffUtil is the lower-level API you can use to compute the diffs yourself. Each approach allows you to specify how diffs should be computed based on item data.

    List mutation with SortedListIf your RecyclerView receives updates incrementally, e.g. item X is inserted, or item Y is removed, you can use SortedList to manage your list. You define how to order items, and it will automatically trigger update signals that RecyclerView can use. SortedList works if you only need to handle insert and remove events, and has the benefit that you only ever need to have a single copy of the list in memory. It can also compute differences with replaceAll, but this method is more limited than the list diffing behavior above. Paging LibraryThe Paging library extends the diff-based approach to additionally support paged loading. It provides the androidx.paging.PagedList class that operates as a self-loading list, provided a source of data like a database, or paginated network API. It provides convenient list diffing support out of the box, similar to {@code ListAdapter} and {@code AsyncListDiffer}. For more information about the Paging library, see the library documentation. layoutManager
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public @interface RecyclerView.Orientation
      public class RecyclerView.EdgeEffectFactory

      EdgeEffectFactory lets you customize the over-scroll edge effect for RecyclerViews.

      public class RecyclerView.RecycledViewPool

      RecycledViewPool lets you share Views between multiple RecyclerViews.

      If you want to recycle views across RecyclerViews, create an instance of RecycledViewPooland use setRecycledViewPool.

      RecyclerView automatically creates a pool for itself if you don't provide one.

      public final class RecyclerView.Recycler

      A Recycler is responsible for managing scrapped or detached item views for reuse.

      A "scrapped" view is a view that is still attached to its parent RecyclerView butthat has been marked for removal or reuse.

      Typical use of a Recycler by a LayoutManager will be to obtain views foran adapter's data set representing the data at a given position or item ID.If the view to be reused is considered "dirty" the adapter will be asked to rebind it.If not, the view can be quickly reused by the LayoutManager with no further work.Clean views that have not requested layout may be repositioned by a LayoutManager without remeasurement.

      public abstract class RecyclerView.ViewCacheExtension

      ViewCacheExtension is a helper class to provide an additional layer of view caching that canbe controlled by the developer.

      When getViewForPosition is called, Recycler checks attached scrap andfirst level cache to find a matching View. If it cannot find a suitable View, Recycler willcall the getViewForPositionAndType before checking RecycledViewPool.

      Note that, Recycler never sends Views to this method to be cached. It is developersresponsibility to decide whether they want to keep their Views in this custom cache or letthe default recycling policy handle it.

      public abstract class RecyclerView.Adapter

      Base class for an Adapter

      Adapters provide a binding from an app-specific data set to views that are displayedwithin a RecyclerView.

      public abstract class RecyclerView.LayoutManager

      A LayoutManager is responsible for measuring and positioning item viewswithin a RecyclerView as well as determining the policy for when to recycleitem views that are no longer visible to the user. By changing the LayoutManagera RecyclerView can be used to implement a standard vertically scrolling list,a uniform grid, staggered grids, horizontally scrolling collections and more. Several stocklayout managers are provided for general use.

      If the LayoutManager specifies a default constructor or one with the signature(Context, AttributeSet, {@code int}, {@code int}), RecyclerView willinstantiate and set the LayoutManager when being inflated. Most used properties canbe then obtained from getProperties. In casea LayoutManager specifies both constructors, the non-default constructor will takeprecedence.
      public abstract class RecyclerView.ItemDecoration

      An ItemDecoration allows the application to add a special drawing and layout offsetto specific item views from the adapter's data set. This can be useful for drawing dividersbetween items, highlights, visual grouping boundaries and more.

      All ItemDecorations are drawn in the order they were added, before the itemviews (in onDraw() and after the items (in onDrawOver.

      public interface RecyclerView.OnItemTouchListener

      An OnItemTouchListener allows the application to intercept touch events in progress at theview hierarchy level of the RecyclerView before those touch events are considered forRecyclerView's own scrolling behavior.

      This can be useful for applications that wish to implement various forms of gesturalmanipulation of item views within the RecyclerView. OnItemTouchListeners may intercepta touch interaction already in progress even if the RecyclerView is already handling thatgesture stream itself for the purposes of scrolling.

      public class RecyclerView.SimpleOnItemTouchListener

      An implementation of OnItemTouchListener that has empty method bodiesand default return values.

      You may prefer to extend this class if you don't need to override all methods. Anotherbenefit of using this class is future compatibility. As the interface may change, we'llalways provide a default implementation on this class so that your code won't break whenyou update to a new version of the support library.

      public abstract class RecyclerView.OnScrollListener

      An OnScrollListener can be added to a RecyclerView to receive messages when a scrolling eventhas occurred on that RecyclerView.

      public interface RecyclerView.RecyclerListener

      A RecyclerListener can be set on a RecyclerView to receive messages whenevera view is recycled.

      public interface RecyclerView.OnChildAttachStateChangeListener

      A Listener interface that can be attached to a RecylcerView to get notifiedwhenever a ViewHolder is attached to or detached from RecyclerView.

      public abstract class RecyclerView.ViewHolder

      A ViewHolder describes an item view and metadata about its place within the RecyclerView.

      Adapter implementations should subclass ViewHolder and add fields for cachingpotentially expensive findViewById results.

      While LayoutParams belong to the LayoutManager, ViewHolders belong to the adapter. Adapters should feel free to usetheir own custom ViewHolder implementations to store data that makes binding view contentseasier. Implementations should assume that individual item views will hold strong referencesto ViewHolder objects and that RecyclerView instances may holdstrong references to extra off-screen item views for caching purposes

      public class RecyclerView.LayoutParams

      LayoutParams subclass for children of RecyclerView. Custom layout managers are encouragedto create their own subclass of this LayoutParams classto store any additional required per-child view metadata about the layout.

      public abstract class RecyclerView.AdapterDataObserver

      Observer base class for watching changes to an Adapter.See registerAdapterDataObserver.

      public abstract class RecyclerView.SmoothScroller

      Base class for smooth scrolling. Handles basic tracking of the target view position andprovides methods to trigger a programmatic scroll.

      An instance of SmoothScroller is only intended to be used once. You should create a newinstance for each call to startSmoothScroll.

      public class RecyclerView.SavedState

      This is public so that the CREATOR can be accessed on cold launch.

      public class RecyclerView.State

      Contains useful information about the current RecyclerView state like target scrollposition or view focus. State object can also keep arbitrary data, identified by resourceids.

      Often times, RecyclerView components will need to pass information between each other.To provide a well defined data bus between components, RecyclerView passes the same Stateobject to component callbacks and these components can use it to exchange data.

      If you implement custom components, you can use State's put/get/remove methods to passdata between your components without needing to manage their lifecycles.

      public abstract class RecyclerView.OnFlingListener

      This class defines the behavior of fling if the developer wishes to handle it.

      Subclasses of OnFlingListener can be used to implement custom fling behavior.

      public abstract class RecyclerView.ItemAnimator

      This class defines the animations that take place on items as changes are madeto the adapter.Subclasses of ItemAnimator can be used to implement custom animations for actions onViewHolder items. The RecyclerView will manage retaining these items while theyare being animated, but implementors must call dispatchAnimationFinished when a ViewHolder's animation is finished. In other words, there must be a matching dispatchAnimationFinished call for each animateAppearance(), animateChange()animatePersistence(),and animateDisappearance() call.

      By default, RecyclerView uses DefaultItemAnimator.

      public interface RecyclerView.ChildDrawingOrderCallback

      A callback interface that can be used to alter the drawing order of RecyclerView children.

      It works using the getChildDrawingOrder method, so any casethat applies to that method also applies to this callback. For example, changing the drawingorder of two views will not have any effect if their elevation values are different sinceelevation overrides the result of this callback.

    • Method Summary

      Modifier and Type Method Description
      CharSequence getAccessibilityClassName() Sets the accessibility delegate compatibility implementation used by RecyclerView.
      void setHasFixedSize(boolean hasFixedSize) RecyclerView can perform several optimizations if it can know in advance that RecyclerView'ssize is not affected by the adapter contents.
      boolean hasFixedSize()
      void setClipToPadding(boolean clipToPadding)
      boolean getClipToPadding() Returns whether this RecyclerView will clip its children to its padding, and resize (butnot clip) any EdgeEffect to the padded region, if padding is present.
      void setScrollingTouchSlop(int slopConstant) Configure the scrolling touch slop for a specific use case.Set up the RecyclerView's scrolling motion threshold based on common usages.
      void swapAdapter(@Nullable() RecyclerView.Adapter adapter, boolean removeAndRecycleExistingViews) Swaps the current adapter with the provided one.
      void setAdapter(@Nullable() RecyclerView.Adapter adapter) Set a new adapter to provide child views on demand.
      RecyclerView.Adapter getAdapter() Retrieves the previously set adapter or null if no adapter is set.
      void setRecyclerListener(@Nullable() RecyclerView.RecyclerListener listener) Register a listener that will be notified whenever a child view is recycled.
      void addRecyclerListener(@NonNull() RecyclerView.RecyclerListener listener) Register a listener that will be notified whenever a child view is recycled.
      void removeRecyclerListener(@NonNull() RecyclerView.RecyclerListener listener) Removes the provided listener from RecyclerListener list.
      int getBaseline() Return the offset of the RecyclerView's text baseline from the its topboundary.
      void addOnChildAttachStateChangeListener(@NonNull() RecyclerView.OnChildAttachStateChangeListener listener) Register a listener that will be notified whenever a child view is attached to or detachedfrom RecyclerView.
      void removeOnChildAttachStateChangeListener(@NonNull() RecyclerView.OnChildAttachStateChangeListener listener) Removes the provided listener from child attached state listeners list.
      void clearOnChildAttachStateChangeListeners() Removes all listeners that were added via addOnChildAttachStateChangeListener.
      void setLayoutManager(@Nullable() RecyclerView.LayoutManager layout) Set the LayoutManager that this RecyclerView will use.
      void setOnFlingListener(@Nullable() RecyclerView.OnFlingListener onFlingListener) Set a OnFlingListener for this RecyclerView.
      RecyclerView.OnFlingListener getOnFlingListener() Get the current OnFlingListener from this RecyclerView.
      RecyclerView.LayoutManager getLayoutManager() Return the LayoutManager currently responsible forlayout policy for this RecyclerView.
      RecyclerView.RecycledViewPool getRecycledViewPool() Retrieve this RecyclerView's RecycledViewPool.
      void setRecycledViewPool(@Nullable() RecyclerView.RecycledViewPool pool) Recycled view pools allow multiple RecyclerViews to share a common pool of scrap views.
      void setViewCacheExtension(@Nullable() RecyclerView.ViewCacheExtension extension) Sets a new ViewCacheExtension to be used by the Recycler.
      void setItemViewCacheSize(int size) Set the number of offscreen views to retain before adding them to the potentially shared recycled view pool.
      int getScrollState() Return the current scrolling state of the RecyclerView.
      void addItemDecoration(@NonNull() RecyclerView.ItemDecoration decor, int index) Add an ItemDecoration to this RecyclerView.
      void addItemDecoration(@NonNull() RecyclerView.ItemDecoration decor) Add an ItemDecoration to this RecyclerView.
      RecyclerView.ItemDecoration getItemDecorationAt(int index) Returns an ItemDecoration previously added to this RecyclerView.
      int getItemDecorationCount() Returns the number of ItemDecoration currently added to this RecyclerView.
      void removeItemDecorationAt(int index) Removes the ItemDecoration associated with the supplied index position.
      void removeItemDecoration(@NonNull() RecyclerView.ItemDecoration decor) Remove an ItemDecoration from this RecyclerView.
      void setChildDrawingOrderCallback(@Nullable() RecyclerView.ChildDrawingOrderCallback childDrawingOrderCallback) Sets the ChildDrawingOrderCallback to be used for drawing children.
      void setOnScrollListener(@Nullable() RecyclerView.OnScrollListener listener) Set a listener that will be notified of any changes in scroll state or position.
      void addOnScrollListener(@NonNull() RecyclerView.OnScrollListener listener) Add a listener that will be notified of any changes in scroll state or position.
      void removeOnScrollListener(@NonNull() RecyclerView.OnScrollListener listener) Remove a listener that was notified of any changes in scroll state or position.
      void clearOnScrollListeners() Remove all secondary listener that were notified of any changes in scroll state or position.
      void scrollToPosition(int position) Convenience method to scroll to a certain position.
      void smoothScrollToPosition(int position) Starts a smooth scroll to an adapter position.
      void scrollTo(int x, int y)
      void scrollBy(int x, int y)
      void nestedScrollBy(int x, int y) Same as scrollBy, but also participates in nested scrolling.
      int computeHorizontalScrollOffset() Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontalrange.
      int computeHorizontalScrollExtent() Compute the horizontal extent of the horizontal scrollbar's thumb within thehorizontal range.
      int computeHorizontalScrollRange() Compute the horizontal range that the horizontal scrollbar represents.
      int computeVerticalScrollOffset() Compute the vertical offset of the vertical scrollbar's thumb within the vertical range.This value is used to compute the length of the thumb within the scrollbar's track.
      int computeVerticalScrollExtent() Compute the vertical extent of the vertical scrollbar's thumb within the vertical range.This value is used to compute the length of the thumb within the scrollbar's track.
      int computeVerticalScrollRange() Compute the vertical range that the vertical scrollbar represents.
      final void suppressLayout(boolean suppress) Tells this RecyclerView to suppress all layout and scroll calls until layoutsuppression is disabled with a later call to suppressLayout(false).When layout suppression is disabled, a requestLayout() call is sentif requestLayout() was attempted while layout was being suppressed.
      final boolean isLayoutSuppressed() Returns whether layout and scroll calls on this container are currently beingsuppressed, due to an earlier call to suppressLayout.
      void setLayoutFrozen(boolean frozen) Enable or disable layout and scroll.
      boolean isLayoutFrozen()
      void setLayoutTransition(LayoutTransition transition)
      void smoothScrollBy(@Px() int dx, @Px() int dy) Animate a scroll by the given amount of pixels along either axis.
      void smoothScrollBy(@Px() int dx, @Px() int dy, @Nullable() Interpolator interpolator) Animate a scroll by the given amount of pixels along either axis.
      void smoothScrollBy(@Px() int dx, @Px() int dy, @Nullable() Interpolator interpolator, int duration) Smooth scrolls the RecyclerView by a given distance.
      boolean fling(int velocityX, int velocityY) Begin a standard fling with an initial velocity along each axis in pixels per second.If the velocity given is below the system-defined minimum this method will return falseand no fling will occur.
      void stopScroll() Stop any current scroll in progress, such as one started by smoothScrollBy, fling or a touch-initiated fling.
      int getMinFlingVelocity() Returns the minimum velocity to start a fling.
      int getMaxFlingVelocity() Returns the maximum fling velocity used by this RecyclerView.
      void setEdgeEffectFactory(@NonNull() RecyclerView.EdgeEffectFactory edgeEffectFactory) Set a EdgeEffectFactory for this RecyclerView.
      RecyclerView.EdgeEffectFactory getEdgeEffectFactory() Retrieves the previously set EdgeEffectFactory or the default factory if nothingwas set.
      View focusSearch(View focused, int direction) Since RecyclerView is a collection ViewGroup that includes virtual children (items that arein the Adapter but not visible in the UI), it employs a more involved focus search strategythat differs from other ViewGroups.
      void requestChildFocus(View child, View focused)
      boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate)
      void addFocusables(ArrayList<View> views, int direction, int focusableMode)
      boolean isAttachedToWindow() Returns true if RecyclerView is attached to window.
      void addOnItemTouchListener(@NonNull() RecyclerView.OnItemTouchListener listener) Add an OnItemTouchListener to intercept touch events before they are dispatchedto child views or this view's standard scrolling behavior.
      void removeOnItemTouchListener(@NonNull() RecyclerView.OnItemTouchListener listener) Remove an OnItemTouchListener.
      boolean onInterceptTouchEvent(MotionEvent e)
      void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
      boolean onTouchEvent(MotionEvent e)
      boolean onGenericMotionEvent(MotionEvent event)
      void setItemAnimator(@Nullable() RecyclerView.ItemAnimator animator) Sets the ItemAnimator that will handle animations involving changesto the items in this RecyclerView.
      boolean isComputingLayout() Returns whether RecyclerView is currently computing a layout.
      boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event)
      RecyclerView.ItemAnimator getItemAnimator() Gets the current ItemAnimator for this RecyclerView.
      void requestLayout()
      void draw(Canvas c)
      void onDraw(Canvas c)
      ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
      boolean isAnimating() Returns true if RecyclerView is currently running some animations.
      void invalidateItemDecorations() Invalidates all ItemDecorations.
      boolean getPreserveFocusAfterLayout() Returns true if the RecyclerView should attempt to preserve currently focused Adapter Item'sfocus even if the View representing the Item is replaced during a layout calculation.
      void setPreserveFocusAfterLayout(boolean preserveFocusAfterLayout) Set whether the RecyclerView should try to keep the same Item focused after a layoutcalculation or not.
      RecyclerView.ViewHolder getChildViewHolder(@NonNull() View child) Retrieve the ViewHolder for the given child view.
      View findContainingItemView(@NonNull() View view) Traverses the ancestors of the given view and returns the item view that contains it andalso a direct child of the RecyclerView.
      RecyclerView.ViewHolder findContainingViewHolder(@NonNull() View view) Returns the ViewHolder that contains the given view.
      int getChildPosition(@NonNull() View child)
      int getChildAdapterPosition(@NonNull() View child) Return the adapter position that the given child view corresponds to.
      int getChildLayoutPosition(@NonNull() View child) Return the adapter position of the given child view as of the latest completed layout pass.
      long getChildItemId(@NonNull() View child) Return the stable item id that the given child view corresponds to.
      RecyclerView.ViewHolder findViewHolderForPosition(int position)
      RecyclerView.ViewHolder findViewHolderForLayoutPosition(int position) Return the ViewHolder for the item in the given position of the data set as of the latestlayout pass.
      RecyclerView.ViewHolder findViewHolderForAdapterPosition(int position) Return the ViewHolder for the item in the given position of the data set.
      RecyclerView.ViewHolder findViewHolderForItemId(long id) Return the ViewHolder for the item with the given id.
      View findChildViewUnder(float x, float y) Find the topmost view under the given point.
      boolean drawChild(Canvas canvas, View child, long drawingTime)
      void offsetChildrenVertical(@Px() int dy) Offset the bounds of all child views by dy pixels.
      void onChildAttachedToWindow(@NonNull() View child) Called when an item view is attached to this RecyclerView.
      void onChildDetachedFromWindow(@NonNull() View child) Called when an item view is detached from this RecyclerView.
      void offsetChildrenHorizontal(@Px() int dx) Offset the bounds of all child views by dx pixels.
      void getDecoratedBoundsWithMargins(@NonNull() View view, @NonNull() Rect outBounds) Returns the bounds of the view including its decoration and margins.
      void onScrolled(@Px() int dx, @Px() int dy) Called when the scroll position of this RecyclerView changes.
      void onScrollStateChanged(int state) Called when the scroll state of this RecyclerView changes.
      boolean hasPendingAdapterUpdates() Returns whether there are pending adapter updates which are not yet applied to the layout.
      void setNestedScrollingEnabled(boolean enabled)
      boolean isNestedScrollingEnabled()
      boolean startNestedScroll(int axes)
      boolean startNestedScroll(int axes, int type) Begin a nestable scroll operation along the given axes, for the given input type.
      void stopNestedScroll()
      void stopNestedScroll(int type) Stop a nested scroll in progress for the given input type.
      boolean hasNestedScrollingParent()
      boolean hasNestedScrollingParent(int type) Returns true if this view has a nested scrolling parent for the given input type.
      boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, Array<int> offsetInWindow)
      boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, Array<int> offsetInWindow, int type) Dispatch one step of a nested scroll in progress.
      final void dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, Array<int> offsetInWindow, int type, @NonNull() Array<int> consumed) Dispatch one step of a nested scroll in progress.
      boolean dispatchNestedPreScroll(int dx, int dy, Array<int> consumed, Array<int> offsetInWindow)
      boolean dispatchNestedPreScroll(int dx, int dy, Array<int> consumed, Array<int> offsetInWindow, int type) Dispatch one step of a nested scroll in progress before this view consumes any portion of it.
      boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
      boolean dispatchNestedPreFling(float velocityX, float velocityY)
      • Methods inherited from class android.view.ViewGroup

        addChildrenForAccessibility, addExtraDataToAccessibilityNodeInfo, addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addView, bringChildToFront, childDrawableStateChanged, childHasTransientStateChanged, clearChildFocus, clearDisappearingChildren, clearFocus, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPointerCaptureChanged, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchSetActivated, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowInsetsAnimationEnd, dispatchWindowInsetsAnimationPrepare, dispatchWindowInsetsAnimationProgress, dispatchWindowInsetsAnimationStart, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, endViewTransition, findFocus, findViewsWithText, focusSearch, focusableViewAvailable, gatherTransparentRegion, generateLayoutParams, getAccessibilityClassName, getChildAt, getChildCount, getChildMeasureSpec, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getNestedScrollAxes, getOverlay, getPersistentDrawingCache, getTouchscreenBlocksFocus, hasFocus, hasTransientState, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isLayoutSuppressed, isMotionEventSplittingEnabled, isTransitionGroup, jumpDrawablesToCurrentState, layout, notifySubtreeAccessibilityStateChanged, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onDescendantInvalidated, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestSendAccessibilityEvent, onResolvePointerIcon, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, restoreDefaultFocus, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setTouchscreenBlocksFocus, setTransitionGroup, setWindowInsetsAnimationCallback, shouldDelayChildPressedState, showContextMenuForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, suppressLayout, updateViewLayout
      • Methods inherited from class android.view.View

        addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, animate, announceForAccessibility, autofill, bringToFront, buildDrawingCache, buildLayer, callOnClick, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, checkInputConnectionProxy, clearAnimation, combineMeasuredStates, computeScroll, computeSystemWindowInsets, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, findViewById, findViewWithTag, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getAnimationMatrix, getApplicationWindowToken, getAttributeResolutionStack, getAttributeSourceResourceMap, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintBlendMode, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentCaptureSession, getContentDescription, getContext, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getExplicitStyle, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintBlendMode, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getHandler, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getImportantForAccessibility, getImportantForAutofill, getImportantForContentCapture, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverScrollMode, getOverlay, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getResources, getRevealOnFocusHint, getRight, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getSourceLayoutResId, getStateDescription, getStateListAnimator, getSystemGestureExclusionRects, getSystemUiVisibility, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTouchDelegate, getTouchables, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getUniqueDrawingId, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowId, getWindowInsetsController, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasPointerCapture, hasWindowFocus, inflate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForceDarkAllowed, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isImportantForContentCapture, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingRelative, isPivotSet, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollContainer, isScrollbarFadingEnabled, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, keyboardNavigationClusterSearch, measure, offsetLeftAndRight, offsetTopAndBottom, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onCreateInputConnection, onDragEvent, onDrawForeground, onFilterTouchEventForSecurity, onFinishTemporaryDetach, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideContentCaptureStructure, onProvideStructure, onProvideVirtualStructure, onRtlPropertiesChanged, onScreenStateChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityAggregated, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, performAccessibilityAction, performClick, performContextClick, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocusFromTouch, requestLayout, requestPointerCapture, requestRectangleOnScreen, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreHierarchyState, saveAttributeDataForStyleable, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAutofillHints, setAutofillId, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintBlendMode, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentCaptureSession, setContentDescription, setContextClickable, setDefaultFocusHighlightEnabled, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setForceDarkAllowed, setForeground, setForegroundGravity, setForegroundTintBlendMode, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setImportantForContentCapture, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnCapturedPointerListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollX, setScrollY, setScrollbarFadingEnabled, setSelected, setSoundEffectsEnabled, setStateDescription, setStateListAnimator, setSystemGestureExclusionRects, setSystemUiVisibility, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, updateDragShadow, willNotCacheDrawing, willNotDraw
      • Methods inherited from class tds.androidx.core.view.NestedScrollingChild2

        dispatchNestedPreScroll, dispatchNestedScroll, hasNestedScrollingParent, startNestedScroll, stopNestedScroll
      • Methods inherited from class tds.androidx.core.view.NestedScrollingChild

        dispatchNestedPreScroll, dispatchNestedScroll, startNestedScroll
      • Methods inherited from class tds.androidx.core.view.NestedScrollingChild3

        dispatchNestedScroll
      • Methods inherited from class java.lang.Object

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

      • setHasFixedSize

         void setHasFixedSize(boolean hasFixedSize)

        RecyclerView can perform several optimizations if it can know in advance that RecyclerView'ssize is not affected by the adapter contents. RecyclerView can still change its size basedon other factors (e.g. its parent's size) but this size calculation cannot depend on thesize of its children or contents of its adapter (except the number of items in the adapter).

        If your use of RecyclerView falls into this category, set this to {@code true}. It will allowRecyclerView to avoid invalidating the whole layout when its adapter contents change.

        Parameters:
        hasFixedSize - true if adapter changes cannot affect the size of the RecyclerView.
      • getClipToPadding

         boolean getClipToPadding()

        Returns whether this RecyclerView will clip its children to its padding, and resize (butnot clip) any EdgeEffect to the padded region, if padding is present.

        By default, children are clipped to the padding of their parentRecyclerView. This clipping behavior is only enabled if padding is non-zero.

      • setScrollingTouchSlop

         void setScrollingTouchSlop(int slopConstant)

        Configure the scrolling touch slop for a specific use case.Set up the RecyclerView's scrolling motion threshold based on common usages.Valid arguments are TOUCH_SLOP_DEFAULT and TOUCH_SLOP_PAGING.

        Parameters:
        slopConstant - One of the TOUCH_SLOP_ constants representingthe intended usage of this RecyclerView
      • swapAdapter

         void swapAdapter(@Nullable() RecyclerView.Adapter adapter, boolean removeAndRecycleExistingViews)

        Swaps the current adapter with the provided one. It is similar to setAdapter but assumes existing adapter and the new adapter uses the same ViewHolder and does not clear the RecycledViewPool.

        Note that it still calls onAdapterChanged callbacks.

        Parameters:
        adapter - The new adapter to set, or null to set no adapter.
        removeAndRecycleExistingViews - If set to true, RecyclerView will recycle all existingViews.
      • setAdapter

         void setAdapter(@Nullable() RecyclerView.Adapter adapter)

        Set a new adapter to provide child views on demand.

        When adapter is changed, all existing views are recycled back to the pool. If the pool hasonly one adapter, it will be cleared.

        Parameters:
        adapter - The new adapter to set, or null to set no adapter.
      • setRecyclerListener

        @Deprecated() void setRecyclerListener(@Nullable() RecyclerView.RecyclerListener listener)

        Register a listener that will be notified whenever a child view is recycled.

        This listener will be called when a LayoutManager or the RecyclerView decidesthat a child view is no longer needed. If an application associates expensiveor heavyweight data with item views, this may be a good place to releaseor free those resources.

        Parameters:
        listener - Listener to register, or null to clear
      • addRecyclerListener

         void addRecyclerListener(@NonNull() RecyclerView.RecyclerListener listener)

        Register a listener that will be notified whenever a child view is recycled.

        The listeners will be called when a LayoutManager or the RecyclerView decidesthat a child view is no longer needed. If an application associates data withthe item views being recycled, this may be a good place to releaseor free those resources.

        Parameters:
        listener - Listener to register.
      • getBaseline

         int getBaseline()

        Return the offset of the RecyclerView's text baseline from the its topboundary. If the LayoutManager of this RecyclerView does not support baseline alignment,this method returns -1.

      • addOnChildAttachStateChangeListener

         void addOnChildAttachStateChangeListener(@NonNull() RecyclerView.OnChildAttachStateChangeListener listener)

        Register a listener that will be notified whenever a child view is attached to or detachedfrom RecyclerView.

        This listener will be called when a LayoutManager or the RecyclerView decidesthat a child view is no longer needed. If an application associates expensiveor heavyweight data with item views, this may be a good place to releaseor free those resources.

        Parameters:
        listener - Listener to register
      • setRecycledViewPool

         void setRecycledViewPool(@Nullable() RecyclerView.RecycledViewPool pool)

        Recycled view pools allow multiple RecyclerViews to share a common pool of scrap views.This can be useful if you have multiple RecyclerViews with adapters that use the sameview types, for example if you have several data sets with the same kinds of item viewsdisplayed by a androidx.viewpager.widget.ViewPager.

        Parameters:
        pool - Pool to set.
      • setItemViewCacheSize

         void setItemViewCacheSize(int size)

        Set the number of offscreen views to retain before adding them to the potentially shared recycled view pool.

        The offscreen view cache stays aware of changes in the attached adapter, allowinga LayoutManager to reuse those views unmodified without needing to return to the adapterto rebind them.

        Parameters:
        size - Number of views to cache offscreen before returning them to the generalrecycled view pool
      • getScrollState

         int getScrollState()

        Return the current scrolling state of the RecyclerView.

      • addItemDecoration

         void addItemDecoration(@NonNull() RecyclerView.ItemDecoration decor, int index)

        Add an ItemDecoration to this RecyclerView. Item decorations canaffect both measurement and drawing of individual item views.

        Item decorations are ordered. Decorations placed earlier in the list willbe run/queried/drawn first for their effects on item views. Padding added to viewswill be nested; a padding added by an earlier decoration will mean furtheritem decorations in the list will be asked to draw/pad within the previous decoration'sgiven area.

        Parameters:
        decor - Decoration to add
        index - Position in the decoration chain to insert this decoration at.
      • addItemDecoration

         void addItemDecoration(@NonNull() RecyclerView.ItemDecoration decor)

        Add an ItemDecoration to this RecyclerView. Item decorations canaffect both measurement and drawing of individual item views.

        Item decorations are ordered. Decorations placed earlier in the list willbe run/queried/drawn first for their effects on item views. Padding added to viewswill be nested; a padding added by an earlier decoration will mean furtheritem decorations in the list will be asked to draw/pad within the previous decoration'sgiven area.

        Parameters:
        decor - Decoration to add
      • removeItemDecorationAt

         void removeItemDecorationAt(int index)

        Removes the ItemDecoration associated with the supplied index position.

        Parameters:
        index - The index position of the ItemDecoration to be removed.
      • addOnScrollListener

         void addOnScrollListener(@NonNull() RecyclerView.OnScrollListener listener)

        Add a listener that will be notified of any changes in scroll state or position.

        Components that add a listener should take care to remove it when finished.Other components that take ownership of a view may call clearOnScrollListeners to remove all attached listeners.

        Parameters:
        listener - listener to set
      • clearOnScrollListeners

         void clearOnScrollListeners()

        Remove all secondary listener that were notified of any changes in scroll state or position.

      • scrollToPosition

         void scrollToPosition(int position)

        Convenience method to scroll to a certain position.RecyclerView does not implement scrolling logic, rather forwards the call to scrollToPosition

        Parameters:
        position - Scroll to this adapter position
      • scrollTo

         void scrollTo(int x, int y)
      • scrollBy

         void scrollBy(int x, int y)
      • nestedScrollBy

         void nestedScrollBy(int x, int y)

        Same as scrollBy, but also participates in nested scrolling.

        Parameters:
        x - The amount of horizontal scroll requested
        y - The amount of vertical scroll requested
      • suppressLayout

         final void suppressLayout(boolean suppress)

        Tells this RecyclerView to suppress all layout and scroll calls until layoutsuppression is disabled with a later call to suppressLayout(false).When layout suppression is disabled, a requestLayout() call is sentif requestLayout() was attempted while layout was being suppressed.

        In addition to the layout suppression smoothScrollBy, scrollBy, scrollToPosition and smoothScrollToPosition are dropped; TouchEvents and GenericMotionEvents aredropped; onFocusSearchFailed will not becalled.

        suppressLayout(true) does not prevent app from directly calling , smoothScrollToPosition.

        setAdapter and swapAdapter will automaticallystop suppressing.

        Note: Running ItemAnimator is not stopped automatically, it's caller'sresponsibility to call ItemAnimator.end().

        Parameters:
        suppress - true to suppress layout and scroll, false to re-enable.
      • isLayoutSuppressed

         final boolean isLayoutSuppressed()

        Returns whether layout and scroll calls on this container are currently beingsuppressed, due to an earlier call to suppressLayout.

      • setLayoutFrozen

        @Deprecated() void setLayoutFrozen(boolean frozen)

        Enable or disable layout and scroll. After setLayoutFrozen(true) is called,Layout requests will be postponed until setLayoutFrozen(false) is called;child views are not updated when RecyclerView is frozen, smoothScrollBy, scrollBy, scrollToPosition and smoothScrollToPosition are dropped; TouchEvents and GenericMotionEvents aredropped; onFocusSearchFailed will not becalled.

        setLayoutFrozen(true) does not prevent app from directly calling , smoothScrollToPosition.

        setAdapter and swapAdapter will automaticallystop frozen.

        Note: Running ItemAnimator is not stopped automatically, it's caller'sresponsibility to call ItemAnimator.end().

        Parameters:
        frozen - true to freeze layout and scroll, false to re-enable.
      • smoothScrollBy

         void smoothScrollBy(@Px() int dx, @Px() int dy)

        Animate a scroll by the given amount of pixels along either axis.

        Parameters:
        dx - Pixels to scroll horizontally
        dy - Pixels to scroll vertically
      • smoothScrollBy

         void smoothScrollBy(@Px() int dx, @Px() int dy, @Nullable() Interpolator interpolator)

        Animate a scroll by the given amount of pixels along either axis.

        Parameters:
        dx - Pixels to scroll horizontally
        dy - Pixels to scroll vertically
        interpolator - Interpolator to be used for scrolling.
      • smoothScrollBy

         void smoothScrollBy(@Px() int dx, @Px() int dy, @Nullable() Interpolator interpolator, int duration)

        Smooth scrolls the RecyclerView by a given distance.

        Parameters:
        dx - x distance in pixels.
        dy - y distance in pixels.
        interpolator - Interpolator to be used for scrolling.
        duration - Duration of the animation in milliseconds.
      • fling

         boolean fling(int velocityX, int velocityY)

        Begin a standard fling with an initial velocity along each axis in pixels per second.If the velocity given is below the system-defined minimum this method will return falseand no fling will occur.

        Parameters:
        velocityX - Initial horizontal velocity in pixels per second
        velocityY - Initial vertical velocity in pixels per second
      • getMaxFlingVelocity

         int getMaxFlingVelocity()

        Returns the maximum fling velocity used by this RecyclerView.

      • focusSearch

         View focusSearch(View focused, int direction)

        Since RecyclerView is a collection ViewGroup that includes virtual children (items that arein the Adapter but not visible in the UI), it employs a more involved focus search strategythat differs from other ViewGroups.

        It first does a focus search within the RecyclerView. If this search finds a View that is inthe focus direction with respect to the currently focused View, RecyclerView returns thatchild as the next focus target. When it cannot find such child, it calls onFocusSearchFailed to layout more Viewsin the focus search direction. If LayoutManager adds a View that matches thefocus search criteria, it will be returned as the focus search result. Otherwise,RecyclerView will call parent to handle the focus search like a regular ViewGroup.

        When the direction is FOCUS_FORWARD or FOCUS_BACKWARD, a View thatis not in the focus direction is still valid focus target which may not be the desiredbehavior if the Adapter has more children in the focus direction. To handle this case,RecyclerView converts the focus direction to an absolute direction and makes a preliminaryfocus search in that direction. If there are no Views to gain focus, it will call onFocusSearchFailed before running afocus search with the original (relative) direction. This allows RecyclerView to providebetter candidates to the focus search while still allowing the view system to take focus fromthe RecyclerView and give it to a more suitable child if such child exists.

        Parameters:
        focused - The view that currently has focus
        direction - One of FOCUS_UP, FOCUS_DOWN,FOCUS_LEFT, FOCUS_RIGHT,FOCUS_FORWARD,FOCUS_BACKWARD or 0 for not applicable.
      • isAttachedToWindow

         boolean isAttachedToWindow()

        Returns true if RecyclerView is attached to window.

      • isComputingLayout

         boolean isComputingLayout()

        Returns whether RecyclerView is currently computing a layout.

        If this method returns true, it means that RecyclerView is in a lockdown state and anyattempt to update adapter contents will result in an exception because adapter contentscannot be changed while RecyclerView is trying to compute the layout.

        It is very unlikely that your code will be running during this state as it iscalled by the framework when a layout traversal happens or RecyclerView starts to scrollin response to system events (touch, accessibility etc).

        This case may happen if you have some custom logic to change adapter contents inresponse to a View callback (e.g. focus change callback) which might be triggered during alayout calculation. In these cases, you should just postpone the change using a Handler or asimilar mechanism.

      • isAnimating

         boolean isAnimating()

        Returns true if RecyclerView is currently running some animations.

        If you want to be notified when animations are finished, use isRunning.

      • getPreserveFocusAfterLayout

         boolean getPreserveFocusAfterLayout()

        Returns true if the RecyclerView should attempt to preserve currently focused Adapter Item'sfocus even if the View representing the Item is replaced during a layout calculation.

        By default, this value is {@code true}.

      • setPreserveFocusAfterLayout

         void setPreserveFocusAfterLayout(boolean preserveFocusAfterLayout)

        Set whether the RecyclerView should try to keep the same Item focused after a layoutcalculation or not.

        Usually, LayoutManagers keep focused views visible before and after layout but sometimes,views may lose focus during a layout calculation as their state changes or they are replacedwith another view due to type change or animation. In these cases, RecyclerView can requestfocus on the new view automatically.

        Parameters:
        preserveFocusAfterLayout - Whether RecyclerView should preserve focused Item during alayout calculations.
      • findContainingItemView

        @Nullable() View findContainingItemView(@NonNull() View view)

        Traverses the ancestors of the given view and returns the item view that contains it andalso a direct child of the RecyclerView. This returned view can be used to get theViewHolder by calling getChildViewHolder.

        Parameters:
        view - The view that is a descendant of the RecyclerView.
      • getChildAdapterPosition

         int getChildAdapterPosition(@NonNull() View child)

        Return the adapter position that the given child view corresponds to.

        Parameters:
        child - Child View to query
      • getChildLayoutPosition

         int getChildLayoutPosition(@NonNull() View child)

        Return the adapter position of the given child view as of the latest completed layout pass.

        This position may not be equal to Item's adapter position if there are pending changesin the adapter which have not been reflected to the layout yet.

        Parameters:
        child - Child View to query
      • getChildItemId

         long getChildItemId(@NonNull() View child)

        Return the stable item id that the given child view corresponds to.

        Parameters:
        child - Child View to query
      • findViewHolderForLayoutPosition

        @Nullable() RecyclerView.ViewHolder findViewHolderForLayoutPosition(int position)

        Return the ViewHolder for the item in the given position of the data set as of the latestlayout pass.

        This method checks only the children of RecyclerView. If the item at the givenposition is not laid out, it will not create a new one.

        Note that when Adapter contents change, ViewHolder positions are not updated until thenext layout calculation. If there are pending adapter updates, the return value of thismethod may not match your adapter contents. You can use#getBindingAdapterPosition to get the current adapter positionof a ViewHolder. If the Adapter that is assigned to the RecyclerView is an adapterthat combines other adapters (e.g. ConcatAdapter), you can use the getBindingAdapter) to find the position relative to the Adapter that bound the ViewHolder.

        When the ItemAnimator is running a change animation, there might be 2 ViewHolderswith the same layout position representing the same Item. In this case, the updatedViewHolder will be returned.

        Parameters:
        position - The position of the item in the data set of the adapter
      • findViewHolderForAdapterPosition

        @Nullable() RecyclerView.ViewHolder findViewHolderForAdapterPosition(int position)

        Return the ViewHolder for the item in the given position of the data set. Unlike findViewHolderForLayoutPosition this method takes into account any pendingadapter changes that may not be reflected to the layout yet. On the other hand, if notifyDataSetChanged has been called but the new layout has not beencalculated yet, this method will return null since the new positions of viewsare unknown until the layout is calculated.

        This method checks only the children of RecyclerView. If the item at the givenposition is not laid out, it will not create a new one.

        When the ItemAnimator is running a change animation, there might be 2 ViewHoldersrepresenting the same Item. In this case, the updated ViewHolder will be returned.

        Parameters:
        position - The position of the item in the data set of the adapter
      • findViewHolderForItemId

         RecyclerView.ViewHolder findViewHolderForItemId(long id)

        Return the ViewHolder for the item with the given id. The RecyclerView mustuse an Adapter with stableIds toreturn a non-null value.

        This method checks only the children of RecyclerView. If the item with the givenid is not laid out, it will not create a new one.When the ItemAnimator is running a change animation, there might be 2 ViewHolders with thesame id. In this case, the updated ViewHolder will be returned.

        Parameters:
        id - The id for the requested item
      • findChildViewUnder

        @Nullable() View findChildViewUnder(float x, float y)

        Find the topmost view under the given point.

        Parameters:
        x - Horizontal position in pixels to search
        y - Vertical position in pixels to search
      • offsetChildrenVertical

         void offsetChildrenVertical(@Px() int dy)

        Offset the bounds of all child views by dy pixels.Useful for implementing simple scrolling in LayoutManagers.

        Parameters:
        dy - Vertical pixel offset to apply to the bounds of all child views
      • onChildAttachedToWindow

         void onChildAttachedToWindow(@NonNull() View child)

        Called when an item view is attached to this RecyclerView.

        Subclasses of RecyclerView may want to perform extra bookkeeping or modificationsof child views as they become attached. This will be called before a LayoutManager measures or lays out the view and is a good time to perform thesechanges.

        Parameters:
        child - Child view that is now attached to this RecyclerView and its associated window
      • onChildDetachedFromWindow

         void onChildDetachedFromWindow(@NonNull() View child)

        Called when an item view is detached from this RecyclerView.

        Subclasses of RecyclerView may want to perform extra bookkeeping or modificationsof child views as they become detached. This will be called as a LayoutManager fully detaches the child view from the parent and its window.

        Parameters:
        child - Child view that is now detached from this RecyclerView and its associated window
      • offsetChildrenHorizontal

         void offsetChildrenHorizontal(@Px() int dx)

        Offset the bounds of all child views by dx pixels.Useful for implementing simple scrolling in LayoutManagers.

        Parameters:
        dx - Horizontal pixel offset to apply to the bounds of all child views
      • getDecoratedBoundsWithMargins

         void getDecoratedBoundsWithMargins(@NonNull() View view, @NonNull() Rect outBounds)

        Returns the bounds of the view including its decoration and margins.

        Parameters:
        view - The view element to check
        outBounds - A rect that will receive the bounds of the element including itsdecoration and margins.
      • onScrolled

         void onScrolled(@Px() int dx, @Px() int dy)

        Called when the scroll position of this RecyclerView changes. Subclasses should usethis method to respond to scrolling within the adapter's data set instead of an explicitlistener.

        This method will always be invoked before listeners. If a subclass needs to performany additional upkeep or bookkeeping after scrolling but before listeners run,this is a good place to do so.

        This differs from onScrollChanged in that it receivesthe distance scrolled in either direction within the adapter's data set instead of absolutescroll coordinates. Since RecyclerView cannot compute the absolute scroll position fromany arbitrary point in the data set, onScrollChanged will always receivethe current getScrollX and getScrollY values whichdo not correspond to the data set scroll position. However, some subclasses may chooseto use these fields as special offsets.

        Parameters:
        dx - horizontal distance scrolled in pixels
        dy - vertical distance scrolled in pixels
      • onScrollStateChanged

         void onScrollStateChanged(int state)

        Called when the scroll state of this RecyclerView changes. Subclasses should use thismethod to respond to state changes instead of an explicit listener.

        This method will always be invoked before listeners, but after the LayoutManagerresponds to the scroll state change.

        Parameters:
        state - the new scroll state, one of SCROLL_STATE_IDLE,SCROLL_STATE_DRAGGING or SCROLL_STATE_SETTLING
      • hasPendingAdapterUpdates

         boolean hasPendingAdapterUpdates()

        Returns whether there are pending adapter updates which are not yet applied to the layout.

        If this method returns true, it means that what user is currently seeing may notreflect them adapter contents (depending on what has changed).You may use this information to defer or cancel some operations.

        This method returns true if RecyclerView has not yet calculated the first layout after it isattached to the Window or the Adapter has been replaced.

      • startNestedScroll

         boolean startNestedScroll(int axes, int type)

        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 caseof a touch scroll type this corresponds to the initial ACTION_DOWN.In the case of touch scrolling the nested scroll will be terminated automatically inthe 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 scrollingparent at least partially consumed the scroll and the caller should adjust the amount itscrolls by.

        After applying the remainder of the scroll delta the caller should invoke dispatchNestedScroll, passingboth the delta consumed and the delta unconsumed. A nested scrolling parent may treatthese values differently. See onNestedScroll.

        Parameters:
        axes - Flags consisting of a combination of SCROLL_AXIS_HORIZONTAL and/or SCROLL_AXIS_VERTICAL.
        type - the type of input which cause this scroll event
      • stopNestedScroll

         void stopNestedScroll(int type)

        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 - the type of input which cause this scroll event
      • hasNestedScrollingParent

         boolean hasNestedScrollingParent(int type)

        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 initiateda nested scroll and it was accepted by an ancestor view further up the view hierarchy.

        Parameters:
        type - the type of input which cause this scroll event
      • dispatchNestedScroll

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

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

        Dispatch one step of a nested scroll in progress.

        Implementations of views that support nested scrolling should call this to reportinfo about a scroll in progress to the current nested scrolling parent. If a nested scrollis not currently in progress or nested scrolling is not enabled for this view this method does nothing.

        Compatible View implementations should also call dispatchNestedPreScroll beforeconsuming a component of the scroll event themselves.

        Parameters:
        dxConsumed - Horizontal distance in pixels consumed by this view during this scroll step
        dyConsumed - Vertical distance in pixels consumed by this view during this scroll step
        dxUnconsumed - Horizontal scroll distance in pixels not consumed by this view
        dyUnconsumed - Horizontal scroll distance in pixels not consumed by this view
        offsetInWindow - Optional.
        type - the type of input which cause this scroll event
      • dispatchNestedScroll

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

        Dispatch one step of a nested scroll in progress.

        Implementations of views that support nested scrolling should call this to reportinfo about a scroll in progress to the current nested scrolling parent. If a nested scrollis not currently in progress or nested scrolling is not enabled for this view this method does nothing.

        Compatible View implementations should also call dispatchNestedPreScroll beforeconsuming a component of the scroll event themselves.

        The original nested scrolling child (where the input events were received to start thescroll) must provide a non-null consumed parameter with values {0, 0}.

        Parameters:
        dxConsumed - Horizontal distance in pixels consumed by this view during this scroll step
        dyConsumed - Vertical distance in pixels consumed by this view during this scroll step
        dxUnconsumed - Horizontal scroll distance in pixels not consumed by this view
        dyUnconsumed - Horizontal scroll distance in pixels not consumed by this view
        offsetInWindow - Optional.
        type - the type of input which cause this scroll event
        consumed - Output.
      • dispatchNestedPreScroll

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

        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 nestedscrolling operation to consume some or all of the scroll operation before the child viewconsumes it.

        Parameters:
        dx - Horizontal scroll distance in pixels
        dy - Vertical scroll distance in pixels
        consumed - Output.
        offsetInWindow - Optional.
        type - the type of input which cause this scroll event
      • dispatchNestedFling

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