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 | |
---|---|
Creates a divider |
Public methods | |
---|---|
open Drawable? | |
open Unit |
getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) |
open Unit |
onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) |
open Unit |
setDrawable(@NonNull drawable: Drawable) Sets the |
open Unit |
setOrientation(orientation: Int) Sets the orientation for this divider. |
Inherited functions | |
---|---|
Constants
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. |
getItemOffsets
open fun getItemOffsets(
outRect: Rect,
view: View,
parent: RecyclerView,
state: RecyclerView.State
): Unit
onDraw
open fun onDraw(
c: Canvas,
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 |