public class ItemSpaceDecoration extends RecyclerViewItemDecoration
RecyclerViewItemDecoration implementation that may be used to add a space,
vertically and horizontally, between items displayed in a RecyclerView.
ItemSpaceDecoration Attributes
noneRecyclerView.addItemDecoration(RecyclerView.ItemDecoration)RecyclerViewItemDecoration.Precondition| Constructor and Description |
|---|
ItemSpaceDecoration()
Same as
ItemSpaceDecoration(Context) with null context. |
ItemSpaceDecoration(Context context)
Same as
ItemSpaceDecoration(Context, AttributeSet) with null attrs. |
ItemSpaceDecoration(Context context,
AttributeSet attrs)
Same as
ItemSpaceDecoration(Context, AttributeSet, int) with 0 defStyleAttr. |
ItemSpaceDecoration(Context context,
AttributeSet attrs,
int defStyleAttr)
Same as
ItemSpaceDecoration(Context, AttributeSet, int, int) with 0 defStyleRes. |
ItemSpaceDecoration(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Creates a new instance of ItemSpaceDecoration for the given context.
|
ItemSpaceDecoration(int horizontal,
int vertical)
Same as
ItemSpaceDecoration(int, int, int, int) where the specified horizontal
amount will be used for both, horizontal start and horizontal end amounts, and the vertical
amount will be used similarly for both, vertical start and vertical end amounts. |
ItemSpaceDecoration(int horizontalStart,
int horizontalEnd,
int verticalStart,
int verticalEnd)
Creates a new instance of ItemSpaceDecoration with the specified spacing amounts.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getHorizontalEnd()
Returns the amount of space by which to offset each item at the end in horizontal direction.
|
int |
getHorizontalStart()
Returns the amount of space by which to offset each item at the start in horizontal direction.
|
void |
getItemOffsets(Rect rect,
View view,
RecyclerView parent,
RecyclerView.State state) |
int |
getVerticalEnd()
Returns the amount of space by which to offset each item at the end in vertical direction.
|
int |
getVerticalStart()
Returns the amount of space by which to offset each item at the start in vertical direction.
|
protected void |
updateItemOffsets(Rect rect,
boolean rtlDirection)
Called to update the given rect with the current spacing offsets specified for this
decoration.
|
getPrecondition, setPrecondition, setSkipFirst, setSkipLast, shouldDecorate, skipsFirst, skipsLastgetItemOffsets, onDraw, onDraw, onDrawOver, onDrawOverpublic ItemSpaceDecoration()
ItemSpaceDecoration(Context) with null context.public ItemSpaceDecoration(int horizontal,
int vertical)
ItemSpaceDecoration(int, int, int, int) where the specified horizontal
amount will be used for both, horizontal start and horizontal end amounts, and the vertical
amount will be used similarly for both, vertical start and vertical end amounts.public ItemSpaceDecoration(int horizontalStart,
int horizontalEnd,
int verticalStart,
int verticalEnd)
horizontalStart - Amount to be applied at the start of an item in horizontal direction.horizontalEnd - Amount to be applied at the end of an item in horizontal direction.verticalStart - Amount to be applied at the start of an item in vertical direction.verticalEnd - Amount to be applied at the end of an item in vertical direction.public ItemSpaceDecoration(@Nullable Context context)
ItemSpaceDecoration(Context, AttributeSet) with null attrs.public ItemSpaceDecoration(@Nullable Context context, @Nullable AttributeSet attrs)
ItemSpaceDecoration(Context, AttributeSet, int) with 0 defStyleAttr.public ItemSpaceDecoration(@Nullable Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr)
ItemSpaceDecoration(Context, AttributeSet, int, int) with 0 defStyleRes.public ItemSpaceDecoration(@Nullable Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes 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.ItemSpaceDecoration(int, int, int, int)public int getHorizontalStart()
This value is used with respect to layout direction of the parent RecyclerView.
getHorizontalEnd()public int getHorizontalEnd()
This value is used with respect to layout direction of the parent RecyclerView.
getHorizontalStart()public int getVerticalStart()
getVerticalEnd()public int getVerticalEnd()
getVerticalStart()public void getItemOffsets(@NonNull Rect rect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state)
getItemOffsets in class RecyclerView.ItemDecorationprotected void updateItemOffsets(@NonNull Rect rect, boolean rtlDirection)
rect - The desired item offsets rect to be updated.rtlDirection - True if offsets should be updated for RTL layout direction,
false for LTR layout direction.