StickyHeaderDecoration

class StickyHeaderDecoration(isHeader: (itemPosition: Int) -> Boolean) : RecyclerView.ItemDecoration

A RecyclerView.ItemDecoration used to act as the sticky header in a RecyclerView.

Note:

  • Each RecyclerView should only have one instance of this class added. Adding multiple decorations has no effect and only impacts the performance.

  • In the current implementation, the background of the header item view can not be transparent. Also, if the parent RecyclerView has top padding, android:clipToPadding has to be false in order to draw this decoration properly.

Parameters

isHeader

Determines whether an item at the position is a header or not.

Constructors

Link copied to clipboard
fun StickyHeaderDecoration(isHeader: (itemPosition: Int) -> Boolean)

Functions

Link copied to clipboard
open override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State)
Link copied to clipboard
open override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State)

Inherited functions

Link copied to clipboard
open fun getItemOffsets(@NonNull p0: Rect, p1: Int, @NonNull p2: RecyclerView)
Link copied to clipboard
open fun onDraw(@NonNull p0: Canvas, @NonNull p1: RecyclerView)
open fun onDraw(@NonNull p0: Canvas, @NonNull p1: RecyclerView, @NonNull p2: RecyclerView.State)
Link copied to clipboard
open fun onDrawOver(@NonNull p0: Canvas, @NonNull p1: RecyclerView)