getItemOffsets

open fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State)(source)

Retrieve any offsets for the given item. Each field of outRect specifies the number of pixels that the item view should be inset by, similar to padding or margin. The default implementation sets the bounds of outRect to 0 and returns.

If this ItemDecoration does not affect the positioning of item views, it should set all four fields of outRect (left, top, right, bottom) to zero before returning.

If you need to access Adapter for additional data, you can call getChildAdapterPosition to get the adapter position of the View.

Parameters

outRect

Rect to receive the output.

view

The child view to decorate

parent

RecyclerView this ItemDecoration is decorating

state

The current state of RecyclerView.