DividerItemDecoration

open class DividerItemDecoration : RecyclerView.ItemDecoration
kotlin.Any
   ↳ androidx.recyclerview.widget.RecyclerView.ItemDecoration
   ↳ androidx.recyclerview.widget.DividerItemDecoration

DividerItemDecoration is a RecyclerView.ItemDecoration that can be used as a divider between items of a LinearLayoutManager. It supports both HORIZONTAL and VERTICAL orientations.

 mDividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), mLayoutManager.getOrientation()); recyclerView.addItemDecoration(mDividerItemDecoration); 

Summary

Constants
static Int

static Int

Public constructors
<init>(context: Context!, orientation: Int)

Creates a divider RecyclerView.ItemDecoration that can be used with a LinearLayoutManager.

Public methods
open Unit

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

open Unit
setDrawable(@NonNull drawable: Drawable)

Sets the Drawable for this divider.

open Unit
setOrientation(orientation: Int)

Sets the orientation for this divider.

Inherited functions

Constants

HORIZONTAL

static val HORIZONTAL: Int
Value: LinearLayout.HORIZONTAL

VERTICAL

static val VERTICAL: Int
Value: LinearLayout.VERTICAL

Public constructors

<init>

DividerItemDecoration(context: Context!, orientation: Int)

Creates a divider RecyclerView.ItemDecoration that can be used with a LinearLayoutManager.

Parameters
context Context!: Current context, it will be used to access resources.
orientation Context!: Divider orientation. Should be HORIZONTAL or VERTICAL.

Public methods

onDraw

open fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State): Unit

getItemOffsets

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

setDrawable

open fun setDrawable(@NonNull drawable: Drawable): Unit

Sets the Drawable for this divider.

Parameters
drawable Drawable: Drawable that should be used as a divider.

setOrientation

open fun setOrientation(orientation: Int): Unit

Sets the orientation for this divider. This should be called if RecyclerView.LayoutManager changes orientation.

Parameters
orientation Int: HORIZONTAL or VERTICAL