Package 

Class LinearLayoutManager

    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static int HORIZONTAL
      public final static int VERTICAL
      public final static int INVALID_OFFSET
    • Method Summary

      Modifier and Type Method Description
      boolean isAutoMeasureEnabled() Returns whether the measuring pass of layout should use the AutoMeasure mechanism of RecyclerView or if it should be done by the LayoutManager's implementation of onMeasure.
      RecyclerView.LayoutParams generateDefaultLayoutParams() Create a default LayoutParams object for a child of the RecyclerView.
      boolean getRecycleChildrenOnDetach() Returns whether LayoutManager will recycle its children when it is detached fromRecyclerView.
      void setRecycleChildrenOnDetach(boolean recycleChildrenOnDetach) Set whether LayoutManager will recycle its children when it is detached fromRecyclerView.
      void onDetachedFromWindow(RecyclerView view, RecyclerView.Recycler recycler) Called when this LayoutManager is detached from its parent RecyclerView or whenits parent RecyclerView is detached from its window.
      void onInitializeAccessibilityEvent(AccessibilityEvent event)
      Parcelable onSaveInstanceState() Called when the LayoutManager should save its state.
      void onRestoreInstanceState(Parcelable state) Called when the RecyclerView is ready to restore the state based on a previousRecyclerView.Notice that this might happen after an actual layout, based on how Adapter prefers torestore State.
      boolean canScrollHorizontally()
      boolean canScrollVertically()
      void setStackFromEnd(boolean stackFromEnd) Compatibility support for setStackFromBottom
      boolean getStackFromEnd()
      int getOrientation() Returns the current orientation of the layout.
      void setOrientation(int orientation) Sets the orientation of the layout.
      boolean getReverseLayout() Returns if views are laid out from the opposite direction of the layout.
      void setReverseLayout(boolean reverseLayout) Used to reverse item traversal and layout order.This behaves similar to the layout change for RTL views.
      View findViewByPosition(int position) Finds the view which represents the given adapter position.
      void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) Smooth scroll to the specified adapter position.
      PointF computeScrollVectorForPosition(int targetPosition) Should calculate the vector that points to the direction where the target positioncan be found.
      void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) Lay out all relevant child views from the given adapter.The LayoutManager is in charge of the behavior of item animations.
      void onLayoutCompleted(RecyclerView.State state) Called after a full layout calculation is finished.
      void scrollToPosition(int position) Scroll the RecyclerView to make the position visible.
      void scrollToPositionWithOffset(int position, int offset) Scroll to the specified adapter position with the given offset from resolved layoutstart.
      int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) Scroll horizontally by dx pixels in screen coordinates and return the distance traveled.The default implementation does nothing and returns 0.
      int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) Scroll vertically by dy pixels in screen coordinates and return the distance traveled.The default implementation does nothing and returns 0.
      int computeHorizontalScrollOffset(RecyclerView.State state) Override this method if you want to support scroll bars.
      int computeVerticalScrollOffset(RecyclerView.State state) Override this method if you want to support scroll bars.
      int computeHorizontalScrollExtent(RecyclerView.State state) Override this method if you want to support scroll bars.
      int computeVerticalScrollExtent(RecyclerView.State state) Override this method if you want to support scroll bars.
      int computeHorizontalScrollRange(RecyclerView.State state) Override this method if you want to support scroll bars.
      int computeVerticalScrollRange(RecyclerView.State state) Override this method if you want to support scroll bars.
      void setSmoothScrollbarEnabled(boolean enabled) When smooth scrollbar is enabled, the position and size of the scrollbar thumb is computedbased on the number of visible pixels in the visible items.
      boolean isSmoothScrollbarEnabled() Returns the current state of the smooth scrollbar feature.
      void collectInitialPrefetchPositions(int adapterItemCount, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry) Gather all positions from the LayoutManager to be prefetched in preperation for itsRecyclerView to come on screen, due to the movement of another, containing RecyclerView.
      void setInitialPrefetchItemCount(int itemCount) Sets the number of items to prefetch in collectInitialPrefetchPositions, which defineshow many inner items should be prefetched when this LayoutManager's RecyclerViewis nested inside another RecyclerView.
      int getInitialPrefetchItemCount() Gets the number of items to prefetch in collectInitialPrefetchPositions, which defineshow many inner items should be prefetched when this LayoutManager's RecyclerViewis nested inside another RecyclerView.
      void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry) Gather all positions from the LayoutManager to be prefetched, given specified momentum.
      void assertNotInLayoutOrScroll(String message) Checks if RecyclerView is in the middle of a layout or scroll and throws an IllegalStateException if it is.
      int findFirstVisibleItemPosition() Returns the adapter position of the first visible view.
      int findFirstCompletelyVisibleItemPosition() Returns the adapter position of the first fully visible view.
      int findLastVisibleItemPosition() Returns the adapter position of the last visible view.
      int findLastCompletelyVisibleItemPosition() Returns the adapter position of the last fully visible view.
      View onFocusSearchFailed(View focused, int focusDirection, RecyclerView.Recycler recycler, RecyclerView.State state) Called when searching for a focusable view in the given direction has failedfor the current content of the RecyclerView.
      boolean supportsPredictiveItemAnimations() Returns whether this LayoutManager supports "predictive item animations".
      void prepareForDrop(@NonNull() View view, @NonNull() View target, int x, int y) Called by the after a View is dropped over another View.
      • Methods inherited from class tds.androidx.recyclerview.widget.RecyclerView.LayoutManager

        addDisappearingView, addDisappearingView, addView, addView, assertInLayoutOrScroll, attachView, attachView, attachView, calculateItemDecorationsForChild, checkLayoutParams, chooseSize, collectAdjacentPrefetchPositions, collectInitialPrefetchPositions, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, detachAndScrapAttachedViews, detachAndScrapView, detachAndScrapViewAt, detachView, detachViewAt, endAnimation, findContainingItemView, generateLayoutParams, generateLayoutParams, getBaseline, getBottomDecorationHeight, getChildAt, getChildCount, getChildMeasureSpec, getChildMeasureSpec, getClipToPadding, getColumnCountForAccessibility, getDecoratedBottom, getDecoratedBoundsWithMargins, getDecoratedLeft, getDecoratedMeasuredHeight, getDecoratedMeasuredWidth, getDecoratedRight, getDecoratedTop, getFocusedChild, getHeight, getHeightMode, getItemCount, getItemViewType, getLayoutDirection, getLeftDecorationWidth, getMinimumHeight, getMinimumWidth, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getPosition, getProperties, getRightDecorationWidth, getRowCountForAccessibility, getTopDecorationHeight, getTransformedBoundingBox, getWidth, getWidthMode, hasFocus, ignoreView, isAttachedToWindow, isFocused, isItemPrefetchEnabled, isLayoutHierarchical, isMeasurementCacheEnabled, isSmoothScrolling, isViewPartiallyVisible, layoutDecorated, layoutDecoratedWithMargins, measureChild, measureChildWithMargins, moveView, offsetChildrenHorizontal, offsetChildrenVertical, onAdapterChanged, onAddFocusables, onAttachedToWindow, onDetachedFromWindow, onDetachedFromWindow, onFocusSearchFailed, onInitializeAccessibilityEvent, onInitializeAccessibilityEvent, onInterceptFocusSearch, onItemsAdded, onItemsChanged, onItemsMoved, onItemsRemoved, onItemsUpdated, onItemsUpdated, onLayoutChildren, onLayoutCompleted, onMeasure, onRequestChildFocus, onRequestChildFocus, onScrollStateChanged, postOnAnimation, removeAllViews, removeAndRecycleAllViews, removeAndRecycleView, removeAndRecycleViewAt, removeCallbacks, removeDetachedView, removeView, removeViewAt, requestChildRectangleOnScreen, requestChildRectangleOnScreen, requestLayout, requestSimpleAnimationsInNextLayout, scrollHorizontallyBy, scrollVerticallyBy, setAutoMeasureEnabled, setItemPrefetchEnabled, setMeasuredDimension, setMeasuredDimension, setMeasurementCacheEnabled, smoothScrollToPosition, startSmoothScroll, stopIgnoringView
      • Methods inherited from class java.lang.Object

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

      • LinearLayoutManager

        LinearLayoutManager(Context context)
        Creates a vertical LinearLayoutManager
        Parameters:
        context - Current context, will be used to access resources.
      • LinearLayoutManager

        LinearLayoutManager(Context context, int orientation, boolean reverseLayout)
        Parameters:
        context - Current context, will be used to access resources.
        orientation - Layout orientation.
        reverseLayout - When set to true, layouts from end to start.
      • LinearLayoutManager

        LinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
        Constructor used when layout manager is set in XML by RecyclerView attribute"layoutManager".
    • Method Detail

      • isAutoMeasureEnabled

         boolean isAutoMeasureEnabled()

        Returns whether the measuring pass of layout should use the AutoMeasure mechanism of RecyclerView or if it should be done by the LayoutManager's implementation of onMeasure.

        This method returns false by default (it actually returns the value passed to thedeprecated setAutoMeasureEnabled) and should be overridden to returntrue if a LayoutManager wants to be auto measured by the RecyclerView.

        If this method is overridden to return true, onMeasure should not be overridden.

        AutoMeasure is a RecyclerView mechanism that handles the measuring pass of layout in asimple and contract satisfying way, including the wrapping of children laid out byLayoutManager. Simply put, it handles wrapping children by calling onLayoutChildren during a call to onMeasure, and then calculating desired dimensions basedon children's dimensions and positions. It does this while supporting all existinganimation capabilities of the RecyclerView.

        More specifically:

        • When onMeasure is called, if the provided measurespecs both have a mode of EXACTLY, RecyclerView will set itsmeasured dimensions accordingly and return, allowing layout to continue as normal(Actually, RecyclerView will call onMeasure for backwards compatibilityreasons but it should not be overridden if AutoMeasure is being used).
        • If one of the layout specs is not {@code EXACT}, the RecyclerView will start thelayout process. It will first process all pending Adapter updates andthen decide whether to run a predictive layout. If it decides to do so, it will firstcall onLayoutChildren with isPreLayout set to {@code true}. At this stage, getWidth and getHeight will stillreturn the width and height of the RecyclerView as of the last layout calculation.

          After handling the predictive case, RecyclerView will call onLayoutChildren with isMeasuring set to {@code true} and isPreLayout set to {@code false}. The LayoutManager canaccess the measurement specs via getHeight, getHeightMode, getWidth and getWidthMode.

        • After the layout calculation, RecyclerView sets the measured width & height bycalculating the bounding box for the children (+ RecyclerView's padding). TheLayoutManagers can override setMeasuredDimension to choosedifferent values. For instance, GridLayoutManager overrides this value to handle the casewhere if it is vertical and has 3 columns but only 2 items, it should still measure itswidth to fit 3 items, not 2.
        • Any following calls to onMeasure will run onLayoutChildren with isMeasuring set to {@code true} and isPreLayout set to {@code false}. RecyclerView willtake care of which views are actually added / removed / moved / changed for animations sothat the LayoutManager should not worry about them and handle each onLayoutChildren call as if it is the last one.
        • When measure is complete and RecyclerView's onLayout method is called, RecyclerView checkswhether it already did layout calculations during the measure pass and if so, it re-usesthat information. It may still decide to call onLayoutChildren if the last measure spec was different from the final dimensions or adapter contentshave changed between the measure call and the layout call.
        • Finally, animations are calculated and run as usual.
      • generateDefaultLayoutParams

         RecyclerView.LayoutParams generateDefaultLayoutParams()

        Create a default LayoutParams object for a child of the RecyclerView.

        LayoutManagers will often want to use a custom LayoutParams typeto store extra information specific to the layout. Client code should subclass for this purpose.

        Important: if you use your own custom LayoutParams typeyou must also override #checkLayoutParams(LayoutParams), #generateLayoutParams(ViewGroup.LayoutParams) and #generateLayoutParams(Context, AttributeSet).

      • getRecycleChildrenOnDetach

         boolean getRecycleChildrenOnDetach()

        Returns whether LayoutManager will recycle its children when it is detached fromRecyclerView.

      • setRecycleChildrenOnDetach

         void setRecycleChildrenOnDetach(boolean recycleChildrenOnDetach)

        Set whether LayoutManager will recycle its children when it is detached fromRecyclerView.

        If you are using a RecyclerView.RecycledViewPool, it might be a good idea to setthis flag to true so that views will be available to other RecyclerViewsimmediately.

        Note that, setting this flag will result in a performance drop if RecyclerViewis restored.

        Parameters:
        recycleChildrenOnDetach - Whether children should be recycled in detach or not.
      • onDetachedFromWindow

         void onDetachedFromWindow(RecyclerView view, RecyclerView.Recycler recycler)

        Called when this LayoutManager is detached from its parent RecyclerView or whenits parent RecyclerView is detached from its window.

        LayoutManager should clear all of its View references as another LayoutManager might beassigned to the RecyclerView.

        If the RecyclerView is re-attached with the same LayoutManager and Adapter, it may notcall onLayoutChildren if nothing has changed and a layout wasnot requested on the RecyclerView while it was detached.

        If your LayoutManager has View references that it cleans in on-detach, it should alsocall requestLayout to ensure that it is re-laid out whenRecyclerView is re-attached.

        Subclass implementations should always call through to the superclass implementation.

        Parameters:
        view - The RecyclerView this LayoutManager is bound to
        recycler - The recycler to use if you prefer to recycle your children instead ofkeeping them around.
      • onSaveInstanceState

         Parcelable onSaveInstanceState()

        Called when the LayoutManager should save its state. This is a good time to save yourscroll position, configuration and anything else that may be required to restore the samelayout state if the LayoutManager is recreated.

        RecyclerView does NOT verify if the LayoutManager has changed between state save andrestore. This will let you share information between your LayoutManagers but it is alsoyour responsibility to make sure they use the same parcelable class.

      • onRestoreInstanceState

         void onRestoreInstanceState(Parcelable state)

        Called when the RecyclerView is ready to restore the state based on a previousRecyclerView.Notice that this might happen after an actual layout, based on how Adapter prefers torestore State. See getStateRestorationPolicy for more information.

        Parameters:
        state - The parcelable that was returned by the previous LayoutManager'sonSaveInstanceState method.
      • getOrientation

         int getOrientation()

        Returns the current orientation of the layout.

      • getReverseLayout

         boolean getReverseLayout()

        Returns if views are laid out from the opposite direction of the layout.

      • setReverseLayout

         void setReverseLayout(boolean reverseLayout)

        Used to reverse item traversal and layout order.This behaves similar to the layout change for RTL views. When set to true, first item islaid out at the end of the UI, second item is laid out before it etc.For horizontal layouts, it depends on the layout direction.When set to true, If RecyclerView is LTR, than it willlayout from RTL, if RecyclerView} is RTL, it will layoutfrom LTR.If you are looking for the exact same behavior of setStackFromBottom, use setStackFromEnd

      • findViewByPosition

         View findViewByPosition(int position)

        Finds the view which represents the given adapter position.

        This method traverses each child since it has no information about child order.Override this method to improve performance if your LayoutManager keeps data aboutchild views.

        If a view is ignored via #ignoreView(View), it is also ignored by this method.

      • smoothScrollToPosition

         void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position)

        Smooth scroll to the specified adapter position.

        To support smooth scrolling, override this method, create your SmoothScroller instance and call startSmoothScroll.

        Parameters:
        recyclerView - The RecyclerView to which this layout manager is attached
        state - Current State of RecyclerView
        position - Scroll to this adapter position.
      • computeScrollVectorForPosition

         PointF computeScrollVectorForPosition(int targetPosition)

        Should calculate the vector that points to the direction where the target positioncan be found.

        This method is used by the LinearSmoothScroller to initiate a scroll towardsthe target position.

        The magnitude of the vector is not important. It is always normalized before beingused by the LinearSmoothScroller.

        LayoutManager should not check whether the position exists in the adapter or not.

        Parameters:
        targetPosition - the target position to which the returned vector should point
      • onLayoutChildren

         void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state)

        Lay out all relevant child views from the given adapter.The LayoutManager is in charge of the behavior of item animations. By default,RecyclerView has a non-null #getItemAnimator() ItemAnimator, and simpleitem animations are enabled. This means that add/remove operations on theadapter will result in animations to add new or appearing items, removed ordisappearing items, and moved items. If a LayoutManager returns false from #supportsPredictiveItemAnimations(), which is the default, and runs anormal layout operation during #onLayoutChildren(Recycler, State), theRecyclerView will have enough information to run those animations in a simpleway. For example, the default ItemAnimator, , willsimply fade views in and out, whether they are actually added/removed or whetherthey are moved on or off the screen due to other add/remove operations.

        A LayoutManager wanting a better item animation experience, where items can beanimated onto and off of the screen according to where the items exist when theyare not on screen, then the LayoutManager should return true from #supportsPredictiveItemAnimations() and add additional logic to #onLayoutChildren(Recycler, State). Supporting predictive animationsmeans that #onLayoutChildren(Recycler, State) will be called twice;once as a "pre" layout step to determine where items would have been prior toa real layout, and again to do the "real" layout. In the pre-layout phase,items will remember their pre-layout positions to allow them to be laid outappropriately. Also, LayoutParams#isItemRemoved() removed items willbe returned from the scrap to help determine correct placement of other items.These removed items should not be added to the child list, but should be usedto help calculate correct positioning of other views, including views thatwere not previously onscreen (referred to as APPEARING views), but whosepre-layout offscreen position can be determined given the extrainformation about the pre-layout removed views.

        The second layout pass is the real layout in which only non-removed viewswill be used. The only additional requirement during this pass is, if #supportsPredictiveItemAnimations() returns true, to note whichviews exist in the child list prior to layout and which are not there afterlayout (referred to as DISAPPEARING views), and to position/layout those viewsappropriately, without regard to the actual bounds of the RecyclerView. This allowsthe animation system to know the location to which to animate these disappearingviews.

        The default LayoutManager implementations for RecyclerView handle all of theserequirements for animations already. Clients of RecyclerView can either use oneof these layout managers directly or look at their implementations ofonLayoutChildren() to see how they account for the APPEARING andDISAPPEARING views.

      • onLayoutCompleted

         void onLayoutCompleted(RecyclerView.State state)

        Called after a full layout calculation is finished. The layout calculation may includemultiple onLayoutChildren calls due to animations orlayout measurement but it will include only one onLayoutCompleted call.This method will be called at the end of layout call.

        This is a good place for the LayoutManager to do some cleanup like pending scrollposition, saved state etc.

        Parameters:
        state - Transient state of RecyclerView
      • scrollToPosition

         void scrollToPosition(int position)

        Scroll the RecyclerView to make the position visible.

        RecyclerView will scroll the minimum amount that is necessary to make thetarget position visible. If you are looking for a similar behavior to setSelection or setSelectionFromTop, use scrollToPositionWithOffset.

        Note that scroll position change will not be reflected until the next layout call.

        Parameters:
        position - Scroll to this adapter position
      • scrollToPositionWithOffset

         void scrollToPositionWithOffset(int position, int offset)

        Scroll to the specified adapter position with the given offset from resolved layoutstart. Resolved layout start depends on getReverseLayout, getLayoutDirection and getStackFromEnd.

        For example, if layout is VERTICAL and getStackFromEnd is true, callingscrollToPositionWithOffset(10, 20) will layout such thatitem[10]'s bottom is 20 pixels above the RecyclerView's bottom.

        Note that scroll position change will not be reflected until the next layout call.

        If you are just trying to make a position visible, use scrollToPosition.

        Parameters:
        position - Index (starting at 0) of the reference item.
        offset - The distance (in pixels) between the start edge of the item view andstart edge of the RecyclerView.
      • setSmoothScrollbarEnabled

         void setSmoothScrollbarEnabled(boolean enabled)

        When smooth scrollbar is enabled, the position and size of the scrollbar thumb is computedbased on the number of visible pixels in the visible items. This however assumes that alllist items have similar or equal widths or heights (depending on list orientation).If you use a list in which items have different dimensions, the scrollbar will changeappearance as the user scrolls through the list. To avoid this issue, you need to disablethis property.When smooth scrollbar is disabled, the position and size of the scrollbar thumb is basedsolely on the number of items in the adapter and the position of the visible items insidethe adapter. This provides a stable scrollbar as the user navigates through a list of itemswith varying widths / heights.

        Parameters:
        enabled - Whether or not to enable smooth scrollbar.
      • isSmoothScrollbarEnabled

         boolean isSmoothScrollbarEnabled()

        Returns the current state of the smooth scrollbar feature. It is enabled by default.

      • collectInitialPrefetchPositions

         void collectInitialPrefetchPositions(int adapterItemCount, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry)

        Gather all positions from the LayoutManager to be prefetched in preperation for itsRecyclerView to come on screen, due to the movement of another, containing RecyclerView.

        This method is only called when a RecyclerView is nested in another RecyclerView.

        If item prefetch is enabled for this LayoutManager, as well in another containingLayoutManager, this method is called in between draw traversals to gatherwhich positions this LayoutManager will first need, once it appears on the screen.

        For example, if this LayoutManager represents a horizontally scrolling list within avertically scrolling LayoutManager, this method would be called when the horizontal listis about to come onscreen.

        The LayoutManager should call addPosition foreach item to be prepared, and these positions will have their ViewHolders created andbound, if there is sufficient time available, in advance of being needed by ascroll or layout.

        Parameters:
        adapterItemCount - number of items in the associated adapter.
        layoutPrefetchRegistry - PrefetchRegistry to add prefetch entries into.
      • setInitialPrefetchItemCount

         void setInitialPrefetchItemCount(int itemCount)

        Sets the number of items to prefetch in collectInitialPrefetchPositions, which defineshow many inner items should be prefetched when this LayoutManager's RecyclerViewis nested inside another RecyclerView.

        Set this value to the number of items this inner LayoutManager will display when it isfirst scrolled into the viewport. RecyclerView will attempt to prefetch that number of itemsso they are ready, avoiding jank as the inner RecyclerView is scrolled into the viewport.

        For example, take a vertically scrolling RecyclerView with horizontally scrolling innerRecyclerViews. The rows always have 4 items visible in them (or 5 if not aligned). Passing4 to this method for each inner RecyclerView's LinearLayoutManager will enableRecyclerView's prefetching feature to do create/bind work for 4 views within a row early,before it is scrolled on screen, instead of just the default 2.

        Calling this method does nothing unless the LayoutManager is in a RecyclerViewnested in another RecyclerView.

        Note: Setting this value to be larger than the number ofviews that will be visible in this view can incur unnecessary bind work, and an increase tothe number of Views created and in active use.

        Parameters:
        itemCount - Number of items to prefetch
      • collectAdjacentPrefetchPositions

         void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry)

        Gather all positions from the LayoutManager to be prefetched, given specified momentum.

        If item prefetch is enabled, this method is called in between traversals to gatherwhich positions the LayoutManager will soon need, given upcoming movement in subsequenttraversals.

        The LayoutManager should call addPosition foreach item to be prepared, and these positions will have their ViewHolders created andbound, if there is sufficient time available, in advance of being needed by ascroll or layout.

        Parameters:
        dx - X movement component.
        dy - Y movement component.
        state - State of RecyclerView
        layoutPrefetchRegistry - PrefetchRegistry to add prefetch entries into.
      • findFirstVisibleItemPosition

         int findFirstVisibleItemPosition()

        Returns the adapter position of the first visible view. This position does not includeadapter changes that were dispatched after the last layout pass.

        Note that, this value is not affected by layout orientation or item order traversal.(setReverseLayout). Views are sorted by their positions in the adapter,not in the layout.

        If RecyclerView has item decorators, they will be considered in calculations as well.

        LayoutManager may pre-cache some views that are not necessarily visible. Those viewsare ignored in this method.

      • findFirstCompletelyVisibleItemPosition

         int findFirstCompletelyVisibleItemPosition()

        Returns the adapter position of the first fully visible view. This position does not includeadapter changes that were dispatched after the last layout pass.

        Note that bounds check is only performed in the current orientation. That means, ifLayoutManager is horizontal, it will only check the view's left and right edges.

      • findLastVisibleItemPosition

         int findLastVisibleItemPosition()

        Returns the adapter position of the last visible view. This position does not includeadapter changes that were dispatched after the last layout pass.

        Note that, this value is not affected by layout orientation or item order traversal.(setReverseLayout). Views are sorted by their positions in the adapter,not in the layout.

        If RecyclerView has item decorators, they will be considered in calculations as well.

        LayoutManager may pre-cache some views that are not necessarily visible. Those viewsare ignored in this method.

      • findLastCompletelyVisibleItemPosition

         int findLastCompletelyVisibleItemPosition()

        Returns the adapter position of the last fully visible view. This position does not includeadapter changes that were dispatched after the last layout pass.

        Note that bounds check is only performed in the current orientation. That means, ifLayoutManager is horizontal, it will only check the view's left and right edges.

      • onFocusSearchFailed

         View onFocusSearchFailed(View focused, int focusDirection, RecyclerView.Recycler recycler, RecyclerView.State state)

        Called when searching for a focusable view in the given direction has failedfor the current content of the RecyclerView.

        This is the LayoutManager's opportunity to populate views in the given directionto fulfill the request if it can. The LayoutManager should attach and returnthe view to be focused, if a focusable view in the given direction is found.Otherwise, if all the existing (or the newly populated views) are unfocusable, it returnsthe next unfocusable view to become visible on the screen. This unfocusable view istypically the first view that's either partially or fully out of RV's padded boundedarea in the given direction. The default implementation returns null.

        Parameters:
        focused - The currently focused view
        recycler - The recycler to use for obtaining views for currently offscreen items
        state - Transient state of RecyclerView
      • supportsPredictiveItemAnimations

         boolean supportsPredictiveItemAnimations()

        Returns whether this LayoutManager supports "predictive item animations".

        "Predictive item animations" are automatically created animations that showwhere items came from, and where they are going to, as items are added, removed,or moved within a layout.

        A LayoutManager wishing to support predictive item animations must override thismethod to return true (the default implementation returns false) and must obey certainbehavioral contracts outlined in onLayoutChildren.

        Whether item animations actually occur in a RecyclerView is actually determined by boththe return value from this method and the ItemAnimator set on theRecyclerView itself. If the RecyclerView has a non-null ItemAnimator but thismethod returns false, then only "simple item animations" will be enabled in theRecyclerView, in which views whose position are changing are simply faded in/out. If theRecyclerView has a non-null ItemAnimator and this method returns true, then predictiveitem animations will be enabled in the RecyclerView.

      • prepareForDrop

         void prepareForDrop(@NonNull() View view, @NonNull() View target, int x, int y)

        Called by the after a View is dropped over another View.

        A LayoutManager should implement this interface to get ready for the upcoming moveoperation.

        For example, LinearLayoutManager sets up a "scrollToPositionWithOffset" calls so thatthe View under drag will be used as an anchor View while calculating the next layout,making layout stay consistent.