GridSpacingItemDecoration

class GridSpacingItemDecoration(itemWidth: Int, itemTopBottomSpacing: Int) : RecyclerView.ItemDecoration(source)

A RecyclerView.ItemDecoration that adds spacing around items in a GridLayoutManager.

This decoration applies horizontal and vertical spacing to each item. It skips adding spacing for items whose ViewHolder is an instance of GroupTitleViewHolder or FrameViewHolder.

The spacing is distributed such that the outer edges of the grid have half the spacing, and the inner gaps between items have the full spacing amount.

Parameters

itemWidth

The width of the grid item.

itemTopBottomSpacing

The amount of total top and bottom spacing to apply in pixels.

Constructors

Link copied to clipboard
constructor(itemWidth: Int, itemTopBottomSpacing: Int)

Functions

Link copied to clipboard
open override fun getItemOffsets(rect: Rect, view: View, recyclerView: RecyclerView, state: RecyclerView.State)