GridLayoutManager

public class GridLayoutManager
extends LinearLayoutManager

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


A RecyclerView.LayoutManager implementations that lays out items in a grid.

By default, each item occupies 1 span. You can change it by providing a custom GridLayoutManager.SpanSizeLookup instance via setSpanSizeLookup(SpanSizeLookup).

Summary

Nested classes

class GridLayoutManager.DefaultSpanSizeLookup

Default implementation for GridLayoutManager.SpanSizeLookup

class GridLayoutManager.LayoutParams

LayoutParams used by GridLayoutManager. 

class GridLayoutManager.SpanSizeLookup

A helper class to provide the number of spans each item occupies. 

Constants

int DEFAULT_SPAN_COUNT

Inherited constants

Public constructors

GridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

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

GridLayoutManager(Context context, int spanCount)

Creates a vertical GridLayoutManager

GridLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout)

Public methods

boolean checkLayoutParams(RecyclerView.LayoutParams lp)

Determines the validity of the supplied LayoutParams object.

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.

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.

RecyclerView.LayoutParams generateDefaultLayoutParams()

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

RecyclerView.LayoutParams generateLayoutParams(Context c, AttributeSet attrs)

Create a LayoutParams object suitable for this LayoutManager from an inflated layout resource.

RecyclerView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp)

Create a LayoutParams object suitable for this LayoutManager, copying relevant values from the supplied LayoutParams object if possible.

int getColumnCountForAccessibility(RecyclerView.Recycler recycler, RecyclerView.State state)

Returns the number of columns for accessibility.

int getRowCountForAccessibility(RecyclerView.Recycler recycler, RecyclerView.State state)

Returns the number of rows for accessibility.

int getSpanCount()

Returns the number of spans laid out by this grid.

GridLayoutManager.SpanSizeLookup getSpanSizeLookup()

Returns the current GridLayoutManager.SpanSizeLookup used by the GridLayoutManager.

boolean isUsingSpansToEstimateScrollbarDimensions()

Returns true if the scroll offset and scroll range calculations take account of span information.

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

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

void