LinearSpacing

fun ResourcesScope.LinearSpacing(all: Dimen? = null, between: Dimen? = null, start: Dimen? = null, end: Dimen? = null): RecyclerView.ItemDecoration

An ItemDecoration to add spacing around list items in a Collection. It is intended for use with linear collections (which is the default layout, see CollectionLayouts.Linear), and wont work with grids or staggered grids.

Features include:

  1. equals() implementation (it's a data class) means it will pass prop isEquivalent checks avoiding unnecessary re-renders.

  2. Respects orientation and layout direction.

  3. Specify start/end/between spacing separately.

Example usage:

Collection(
itemDecoration = LinearSpacing(all = 10.dp)
) {}

Parameters

all

Spacing between all items and to the start and end item. If other values are set they will override this value.

between

Spacing between all items

start

Spacing at the front of the first item

end

Spacing at the end of the last item