public abstract static class RecyclerView.ItemDecoration extends Object
All ItemDecorations are drawn in the order they were added, before the item
views (in onDraw()
and after the items (in onDrawOver(Canvas, RecyclerView,
RecyclerView.State)
.
Constructor and Description |
---|
ItemDecoration() |
Modifier and Type | Method and Description |
---|---|
void |
getItemOffsets(Rect outRect,
int itemPosition,
RecyclerView parent)
Deprecated.
Use
#getItemOffsets(Rect, View, RecyclerView, State) |
void |
getItemOffsets(Rect outRect,
View view,
RecyclerView parent,
RecyclerView.State state)
Retrieve any offsets for the given item.
|
void |
onDraw(Canvas c,
RecyclerView parent)
Deprecated.
|
void |
onDraw(Canvas c,
RecyclerView parent,
RecyclerView.State state)
Draw any appropriate decorations into the Canvas supplied to the RecyclerView.
|
void |
onDrawOver(Canvas c,
RecyclerView parent)
Deprecated.
|
void |
onDrawOver(Canvas c,
RecyclerView parent,
RecyclerView.State state)
Draw any appropriate decorations into the Canvas supplied to the RecyclerView.
|
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state)
c
- Canvas to draw intoparent
- RecyclerView this ItemDecoration is drawing intostate
- The current state of RecyclerView@Deprecated public void onDraw(Canvas c, RecyclerView parent)
onDraw(Canvas, RecyclerView, RecyclerView.State)
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state)
c
- Canvas to draw intoparent
- RecyclerView this ItemDecoration is drawing intostate
- The current state of RecyclerView.@Deprecated public void onDrawOver(Canvas c, RecyclerView parent)
onDrawOver(Canvas, RecyclerView, RecyclerView.State)
@Deprecated public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent)
#getItemOffsets(Rect, View, RecyclerView, State)
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state)
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
RecyclerView.getChildAdapterPosition(View)
to get the adapter position of the
View.
outRect
- Rect to receive the output.view
- The child view to decorateparent
- RecyclerView this ItemDecoration is decoratingstate
- The current state of RecyclerView.