Adding dividers
Prior to the RecyclerView, the ListView came with its own divider element. The recycler view, on the other hand, does not. This should not be thought of as a shortfall, however, as this latter approach allows for more flexibility.
It may seem tempting to create a divider by adding a very narrow view at the bottom of the item layout, but this is considered very poor practice as when the item is moved or dismissed, the divider moves with it.
The RecyclerView uses an inner class, ItemDecoration to provide dividers between items, as well as spaces and highlights. It also has a very useful subclass, the ItemTouchHelper, which we will encounter shortly when we see how to swipe and dismiss cards.
First, follow these steps to add dividers to our recycler view:
Create a new ItemDecoration class:
public class ItemDivider extends RecyclerView.ItemDecoration
Include this Drawable field:
Private Drawable divider;
Followed by this constructor:
public ItemDivider(Context context...