Android 12 Developer Preview is here! Try it out, and give us your feedback!

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 Drawable?

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

open Unit

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 Int: Divider orientation. Should be HORIZONTAL or VERTICAL.

Public methods

getDrawable

@Nullable open fun getDrawable(): Drawable?
Return
Drawable? the Drawable for this divider.