Google is committed to advancing racial equity for Black communities. See how.

GridLayoutManager

open class GridLayoutManager : LinearLayoutManager
kotlin.Any
   ↳ 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 SpanSizeLookup instance via setSpanSizeLookup(SpanSizeLookup).

Summary

Nested classes

Default implementation for SpanSizeLookup.

open

LayoutParams used by GridLayoutManager.

abstract

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

Constants
static Int

Inherited constants
Public constructors
<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

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

<init>(context: Context!, spanCount: Int)

Creates a vertical GridLayoutManager

<init>(context: Context!, spanCount: Int, orientation: Int, reverseLayout: Boolean)

Public methods
open Boolean

open Int

open Int

open Int

open Int

open RecyclerView.LayoutParams!

open RecyclerView.LayoutParams!

open RecyclerView.LayoutParams!

open Int

open Int

open Int

Returns the number of spans laid out by this grid.

open GridLayoutManager.SpanSizeLookup!

Returns the current SpanSizeLookup used by the GridLayoutManager.

open Boolean

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

open View?
onFocusSearchFailed(focused: View, focusDirection: Int, recycler: RecyclerView.Recycler, state: RecyclerView.State)

open Unit

open Unit
onItemsAdded(recyclerView: RecyclerView, positionStart: Int, itemCount: Int)

open Unit

open Unit
onItemsMoved(recyclerView: RecyclerView, from: Int, to: Int, itemCount: Int)

open Unit
onItemsRemoved(recyclerView: RecyclerView, positionStart: Int, itemCount: Int)

open Unit
onItemsUpdated(recyclerView: RecyclerView, positionStart: Int, itemCount: Int, payload: Any?)

open Unit

open Unit

open Int

open Int

open Unit
setMeasuredDimension(childrenBounds: Rect!, wSpec: Int, hSpec: Int)

open Unit
setSpanCount(spanCount: Int)

Sets the number of spans to be laid out.

open Unit

Sets the source to get the number of spans occupied by each item in the adapter.

open Unit
setStackFromEnd(stackFromEnd: Boolean)

stackFromEnd is not supported by GridLayoutManager.

open Unit
setUsingSpansToEstimateScrollbarDimensions(useSpansToEstimateScrollBarDimensions: Boolean)

When this flag is set, the scroll offset and scroll range calculations will take account of span information.

open Boolean

Inherited functions