StaggeredGridLayoutManager
open class StaggeredGridLayoutManager : RecyclerView.LayoutManager, RecyclerView.SmoothScroller.ScrollVectorProvider(source)
A LayoutManager that lays out children in a staggered grid formation. It supports horizontal &vertical layout as well as an ability to layout children in reverse.
Staggered grids are likely to have gaps at the edges of the layout. To avoid these gaps, StaggeredGridLayoutManager can offset spans independently or move items between spans. You can control this behavior via setGapStrategy.
Types
Properties
Link copied to clipboard
Link copied to clipboard
When scroll state is changed to SCROLL_STATE_IDLE, StaggeredGrid will check if there are gaps in the because of full span items.
Link copied to clipboard
Does not do anything to hide gaps.
Link copied to clipboard
Functions
Link copied to clipboard
Checks if RecyclerView is in the middle of a layout or scroll and throws an IllegalStateException if it is.
Link copied to clipboard
Query if horizontal scrolling is currently supported.
Link copied to clipboard
Query if vertical scrolling is currently supported.
Link copied to clipboard
Determines the validity of the supplied LayoutParams object.
Link copied to clipboard
open fun collectAdjacentPrefetchPositions(dx: Int, dy: Int, state: RecyclerView.State, layoutPrefetchRegistry: RecyclerView.LayoutManager.LayoutPrefetchRegistry)
Gather all positions from the LayoutManager to be prefetched, given specified momentum.
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
Should calculate the vector that points to the direction where the target position can be found.
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
Returns the adapter position of the first completely visible view for each span.
Link copied to clipboard
Returns the adapter position of the first visible view for each span.
Link copied to clipboard
Returns the adapter position of the last completely visible view for each span.
Link copied to clipboard
Returns the adapter position of the last visible view for each span.
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
open fun getColumnCountForAccessibility(@NonNull recycler: RecyclerView.Recycler, @NonNull state: RecyclerView.State): Int
Returns the number of columns for accessibility.
Link copied to clipboard
Returns the current gap handling strategy for StaggeredGridLayoutManager.
Link copied to clipboard
Link copied to clipboard
Returns whether views are laid out in reverse order or not.
Link copied to clipboard
open fun getRowCountForAccessibility(@NonNull recycler: RecyclerView.Recycler, @NonNull state: RecyclerView.State): Int
Returns the number of rows for accessibility.
Link copied to clipboard
Returns the number of spans laid out by StaggeredGridLayoutManager.
Link copied to clipboard
For consistency, StaggeredGridLayoutManager keeps a mapping between spans and items.
Link copied to clipboard
Returns whether the measuring pass of layout should use the AutoMeasure mechanism of RecyclerView or if it should be done by the LayoutManager's implementation of onMeasure.
Link copied to clipboard
Query if the layout is in reverse order.
Link copied to clipboard
Offset all child views attached to the parent RecyclerView by dx pixels along the horizontal axis.
Link copied to clipboard
Offset all child views attached to the parent RecyclerView by dy pixels along the vertical axis.
Link copied to clipboard
open fun onAdapterChanged(@Nullable oldAdapter: RecyclerView.Adapter, @Nullable newAdapter: RecyclerView.Adapter)
Called if the RecyclerView this LayoutManager is bound to has a different adapter set via setAdapter or swapAdapter.
Link copied to clipboard
Called when this LayoutManager is detached from its parent RecyclerView or when its parent RecyclerView is detached from its window.
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
Link copied to clipboard
open fun onInitializeAccessibilityNodeInfo(@NonNull recycler: RecyclerView.Recycler, @NonNull state: RecyclerView.State, @NonNull info: AccessibilityNodeInfoCompat)
Called by the AccessibilityDelegate when the information about the current layout should be populated.
Link copied to clipboard
open fun onInitializeAccessibilityNodeInfoForItem(@NonNull recycler: RecyclerView.Recycler, @NonNull state: RecyclerView.State, @NonNull host: View, @NonNull info: AccessibilityNodeInfoCompat)
Called by the AccessibilityDelegate when the accessibility information for a specific item should be populated.
Link copied to clipboard
Called when items have been added to the adapter.
Link copied to clipboard
Called in response to a call to notifyDataSetChanged or swapAdapter ()} and signals that the the entire data set has changed.
Link copied to clipboard
Called when an item is moved withing the adapter.
Link copied to clipboard
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
Called when the RecyclerView is ready to restore the state based on a previous RecyclerView.
Link copied to clipboard
Called when the LayoutManager should save its state.
Link copied to clipboard
RecyclerView calls this method to notify LayoutManager that scroll state has changed.
Link copied to clipboard
open fun scrollHorizontallyBy(dx: Int, recycler: RecyclerView.Recycler, state: RecyclerView.State): Int
Scroll horizontally by dx pixels in screen coordinates and return the distance traveled.
Link copied to clipboard
Scroll to the specified adapter position.
Link copied to clipboard
Scroll to the specified adapter position with the given offset from layout start.
Link copied to clipboard
open fun scrollVerticallyBy(dy: Int, recycler: RecyclerView.Recycler, state: RecyclerView.State): Int
Scroll vertically by dy pixels in screen coordinates and return the distance traveled.
Link copied to clipboard
Sets the gap handling strategy for StaggeredGridLayoutManager.
Link copied to clipboard
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
Sets the orientation of the layout.
Link copied to clipboard
Sets whether LayoutManager should start laying out items from the end of the UI.
Link copied to clipboard
Sets the number of spans for the layout.
Link copied to clipboard
open fun smoothScrollToPosition(recyclerView: RecyclerView, state: RecyclerView.State, position: Int)
Smooth scroll to the specified adapter position.
Link copied to clipboard
Returns whether this LayoutManager supports "predictive item animations".