Tutorial by Examples

This will draw a line at the bottom of every view but the last to act as a separator between items. public class SeparatorDecoration extends RecyclerView.ItemDecoration { private final Paint mPaint; private final int mAlpha; public SeparatorDecoration(@ColorInt int color, float w...
You can use a RecyclerView.ItemDecoration to put extra margins around each item in a RecyclerView. This can in some cases clean up both your adapter implementation and your item view XML. public class MyItemDecoration extends RecyclerView.ItemDecoration { private final int extraMargin; ...
First of all you need to create a class which extends RecyclerView.ItemDecoration : public class SimpleBlueDivider extends RecyclerView.ItemDecoration { private Drawable mDivider; public SimpleBlueDivider(Context context) { mDivider = context.getResources().getDrawable(R.drawable.divider_b...
The DividerItemDecoration is a RecyclerView.ItemDecoration that can be used as a divider between items. DividerItemDecoration mDividerItemDecoration = new DividerItemDecoration(context, mLayoutManager.getOrientation()); recyclerView.addItemDecoration(mDividerItemDecoration); It su...
Following example will help to give equal space to an item in GridLayout. ItemOffsetDecoration.java public class ItemOffsetDecoration extends RecyclerView.ItemDecoration { private int mItemOffset; private int spanCount = 2; public ItemOffsetDecoration(int itemOffset) { ...

Page 1 of 1