public abstract class RecyclerViewItemDecoration
extends RecyclerView.ItemDecoration
RecyclerView.ItemDecoration implementation that is used as base class by all item
decorations from the Recycler library and is also encouraged to be used as base class by custom
decoration implementations.
ItemDecoration Attributes
noneRecyclerView#addItemDecoration(RecyclerView.ItemDecoration)| Constructor and Description |
|---|
RecyclerViewItemDecoration()
Same as
RecyclerViewItemDecoration(Context) with null context. |
RecyclerViewItemDecoration(android.content.Context context)
Same as
RecyclerViewItemDecoration(Context, AttributeSet) with null attrs. |
RecyclerViewItemDecoration(android.content.Context context,
android.util.AttributeSet attrs)
Same as
RecyclerViewItemDecoration(Context, AttributeSet, int) with 0
defStyleAttr. |
RecyclerViewItemDecoration(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
Same as
RecyclerViewItemDecoration(Context, AttributeSet, int, int) with 0
defStyleRes. |
RecyclerViewItemDecoration(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Creates a new instance of RecyclerViewItemDecoration for the given context.
|
| Modifier and Type | Method and Description |
|---|---|
void |
setSkipFirst(boolean skip)
Sets a boolean flag indicating whether this decoration should be skipped for the first item
from data set of the associated
RecyclerView. |
void |
setSkipLast(boolean skip)
Sets a boolean flag indicating whether this decoration should be skipped for the last item
from data set of the associated
RecyclerView. |
protected boolean |
shouldDecorate(RecyclerView parent,
RecyclerView.State state)
Checks whether any subsequent decoration algorithm should be applied by this decoration for
the given parent RecyclerView and its current state.
|
boolean |
skipsFirst()
Checks whether this decoration is skipped for the first item.
|
boolean |
skipsLast()
Checks whether this decoration is skipped for the last item.
|
public RecyclerViewItemDecoration()
RecyclerViewItemDecoration(Context) with null context.public RecyclerViewItemDecoration(android.content.Context context)
RecyclerViewItemDecoration(Context, AttributeSet) with null attrs.public RecyclerViewItemDecoration(android.content.Context context,
android.util.AttributeSet attrs)
RecyclerViewItemDecoration(Context, AttributeSet, int) with 0
defStyleAttr.public RecyclerViewItemDecoration(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
RecyclerViewItemDecoration(Context, AttributeSet, int, int) with 0
defStyleRes.public RecyclerViewItemDecoration(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
context - Context in which will be the new decoration presented.attrs - Set of Xml attributes used to configure the new instance of this decoration.defStyleAttr - An attribute which contains a reference to a default style resource for
this decoration within a theme of the given context.defStyleRes - Resource id of the default style for the new decoration.public void setSkipFirst(boolean skip)
RecyclerView.
Default value: false
skip - True to not apply this decoration for the first item, false to
apply it.skipsFirst(),
setSkipLast(boolean)public boolean skipsFirst()
True if this decoration is not applied for the first item, false if
it is.setSkipFirst(boolean)public void setSkipLast(boolean skip)
RecyclerView.
Default value: false
skip - True to not apply this decoration for the last item, false to
apply it.skipsFirst(),
setSkipFirst(boolean)public boolean skipsLast()
True if this decoration is not applied for the last item, false if
it is.setSkipLast(boolean)protected boolean shouldDecorate(RecyclerView parent,
RecyclerView.State state)
This implementation checks whether the given RecyclerView has its RecyclerView.LayoutManager
specified by RecyclerView.getLayoutManager() != null and if there are any items to be
decorated by RecyclerView.State.getItemCount() > 0. If both conditions are met, this
method returns true, if not, false is returned.
parent - The RecyclerView into which is this decoration added.state - Current state of the parent RecyclerView.True if decorating should be performed, false otherwise.