GridLayoutManager

public final class GridLayoutManager
extends RecyclerView.LayoutManager

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


A RecyclerView.LayoutManager implementation that lays out items in a grid for leanback VerticalGridView and HorizontalGridView.

Summary

Public constructors

GridLayoutManager()

Public methods

boolean canScrollHorizontally()

Query if horizontal scrolling is currently supported.

boolean canScrollVertically()

Query if vertical scrolling is currently supported.

boolean checkLayoutParams(RecyclerView.LayoutParams lp)

Determines the validity of the supplied LayoutParams object.

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.

RecyclerView.LayoutParams generateDefaultLayoutParams()

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

RecyclerView.LayoutParams generateLayoutParams(Context context, 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 getDecoratedBottom(View child)

Returns the bottom edge of the given child view within its parent, offset by any applied ItemDecorations.

void getDecoratedBoundsWithMargins(View view, Rect outBounds)

Returns the bounds of the view including its decoration and margins.

int getDecoratedLeft(View child)

Returns the left edge of the given child view within its parent, offset by any applied ItemDecorations.

int getDecoratedRight(View child)

Returns the right edge of the given child view within its parent, offset by any applied ItemDecorations.

int getDecoratedTop(View child)

Returns the top edge of the given child view within its parent, offset by any applied ItemDecorations.

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

Returns the number of rows for accessibility.

void onAdapterChanged(Adapter oldAdapter, Adapter newAdapter)

Called if the RecyclerView this LayoutManager is bound to has a different adapter set via RecyclerView.setAdapter(Adapter) or RecyclerView.swapAdapter(Adapter, boolean).

boolean onAddFocusables(RecyclerView recyclerView, ArrayList<View> views, int direction, int focusableMode)

Called to populate focusable views within the RecyclerView.

void onInitializeAccessibilityNodeInfo(RecyclerView.Recycler recycler, RecyclerView.State state, AccessibilityNodeInfoCompat info)

Called by the AccessibilityDelegate when the information about the current layout should be populated.

void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler, RecyclerView.State state, View host, AccessibilityNodeInfoCompat info)

Called by the AccessibilityDelegate when the accessibility information for a specific item should be populated.

View onInterceptFocusSearch(View focused, int direction)

This method gives a LayoutManager an opportunity to intercept the initial focus search before the default behavior of FocusFinder is used.

void onItemsAdded(RecyclerView recyclerView, int positionStart, int itemCount)

Called when items have been added to the adapter.

void onItemsChanged(RecyclerView recyclerView)

Called in response to a call to