LinearLayoutManager

public class LinearLayoutManager
extends RecyclerView.LayoutManager implements ItemTouchHelper.ViewDropHandler, RecyclerView.SmoothScroller.ScrollVectorProvider

java.lang.Object
   ↳ androidx.recyclerview.widget.RecyclerView.LayoutManager
     ↳ androidx.recyclerview.widget.LinearLayoutManager


A RecyclerView.LayoutManager implementation which provides similar functionality to ListView.

Summary

Nested classes

class LinearLayoutManager.LayoutChunkResult

 

Constants

int HORIZONTAL

int INVALID_OFFSET

int VERTICAL

Public constructors

LinearLayoutManager(Context context)

Creates a vertical LinearLayoutManager

LinearLayoutManager(Context context, int orientation, boolean reverseLayout)
LinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Constructor used when layout manager is set in XML by RecyclerView attribute "layoutManager".

Public methods

void assertNotInLayoutOrScroll(String message)

Checks if RecyclerView is in the middle of a layout or scroll and throws an IllegalStateException if it is.

boolean canScrollHorizontally()

Query if horizontal scrolling is currently supported.

boolean canScrollVertically()

Query if vertical scrolling is currently supported.

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 collectInitialPrefetchPositions(int adapterItemCount, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry)

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

int computeHorizontalScrollExtent(RecyclerView.State state)

Override this method if you want to support scroll bars.

int computeHorizontalScrollOffset(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.

PointF computeScrollVectorForPosition(int targetPosition)

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

int computeVerticalScrollExtent(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 computeVerticalScrollRange(RecyclerView.State state)

Override this method if you want to support scroll bars.

int findFirstCompletelyVisibleItemPosition()

Returns the adapter position of the first fully visible view.

int findFirstVisibleItemPosition()

Returns the adapter position of the first visible view.

int findLastCompletelyVisibleItemPosition()

Returns the adapter position of the last fully visible view.

int findLastVisibleItemPosition()

Returns the adapter position of the last visible view.

View findViewByPosition(int position)

Finds the view which represents the given adapter position.

RecyclerView.LayoutParams generateDefaultLayoutParams()

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

int getInitialPrefetchItemCount()

Gets the number of items to prefetch in collectInitialPrefetchPositions(int, LayoutPrefetchRegistry), which defines how many inner items should be prefetched when this LayoutManager's RecyclerView is nested inside another RecyclerView.

int getOrientation()

Returns the current orientation of the layout.

boolean getRecycleChildrenOnDetach()

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

boolean getReverseLayout()

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

boolean getStackFromEnd()
boolean isAutoMeasureEnabled()

Returns whether the measuring pass of layout should use the AutoMeasure mechanism of RecyclerView or if it should be done by the Layou