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.

Constructors

Link copied to clipboard
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int)
Constructor used when layout manager is set in XML by RecyclerView attribute "layoutManager".
constructor(context: Context, spanCount: Int)
Creates a vertical GridLayoutManager
constructor(context: Context, spanCount: Int, orientation: Int, reverseLayout: Boolean)

Types

Link copied to clipboard
Link copied to clipboard
LayoutParams used by GridLayoutManager.
Link copied to clipboard
abstract class SpanSizeLookup
A helper class to provide the number of spans each item occupies.

Properties

Link copied to clipboard

Functions

Link copied to clipboard
Determines the validity of the supplied LayoutParams object.
Link copied to clipboard
Override this method if you want to support scroll bars.
Link copied to clipboard
Override this method if you want to support scroll bars.
Link copied to clipboard
Override this method if you want to support scroll bars.
Link copied to clipboard
Override this method if you want to support scroll bars.
Link copied to clipboard
Create a default LayoutParams object for a child of the RecyclerView.
Link copied to clipboard
Create a LayoutParams object suitable for this LayoutManager, copying relevant values from the supplied LayoutParams object if possible.
Create a LayoutParams object suitable for this LayoutManager from an inflated layout resource.
Link copied to clipboard
Returns the number of columns for accessibility.
Link copied to clipboard
Returns the number of rows for accessibility.
Link copied to clipboard
open fun getSpanCount(): Int
Returns the number of spans laid out by this grid.
Link copied to clipboard
Returns the current SpanSizeLookup used by the GridLayoutManager.
Returns true if the scroll offset and scroll range calculations take account of span information.
Link copied to clipboard
open fun onFocusSearchFailed(focused: View, direction: Int, recycler: RecyclerView.Recycler, state: RecyclerView.State): View
Called when searching for a focusable view in the given direction has failed for the current content of the RecyclerView.
Link copied to clipboard
Called by the AccessibilityDelegate when the information about the current layout should be populated.
Link copied to clipboard
Called by the AccessibilityDelegate when the accessibility information for a specific item should be populated.
Link copied to clipboard
open fun onItemsAdded(recyclerView: RecyclerView, positionStart: Int, itemCount: Int)
Called when items have been added to the adapter.
Link copied to clipboard
open fun onItemsChanged(recyclerView: RecyclerView)
Called in response to a call to notifyDataSetChanged or swapAdapter ()} and signals that the the entire data set has changed.
Link copied to clipboard
open fun onItemsMoved(recyclerView: RecyclerView, from: Int, to: Int, itemCount: Int)
Called when an item is moved withing the adapter.
Link copied to clipboard
open fun onItemsRemoved(recyclerView: RecyclerView, positionStart: Int, itemCount: Int)
Called when items have been removed from the adapter.
Link copied to clipboard
open fun onItemsUpdated(recyclerView: RecyclerView, positionStart: Int, itemCount: Int, payload: Any)
Called when items have been changed in the adapter and with optional payload.
Link copied to clipboard
Lay out all relevant child views from the given adapter.
Link copied to clipboard
Called after a full layout calculation is finished.
Link copied to clipboard
Scroll horizontally by dx pixels in screen coordinates and return the distance traveled.
Link copied to clipboard
Scroll vertically by dy pixels in screen coordinates and return the distance traveled.
Link copied to clipboard
open fun setMeasuredDimension(childrenBounds: Rect, wSpec: Int, hSpec: Int)
Sets the measured dimensions from the given bounding box of the children and the measurement specs that were passed into onMeasure.
Link copied to clipboard
open fun setSpanCount(spanCount: Int)
Sets the number of spans to be laid out.
Link copied to clipboard
Sets the source to get the number of spans occupied by each item in the adapter.
Link copied to clipboard
open fun setStackFromEnd(stackFromEnd: Boolean)
stackFromEnd is not supported by GridLayoutManager.
open fun setUsingSpansToEstimateScrollbarDimensions(useSpansToEstimateScrollBarDimensions: Boolean)
When this flag is set, the scroll offset and scroll range calculations will take account of span information.
Link copied to clipboard
Returns whether this LayoutManager supports "predictive item animations".