Design + Code an Android App from Scratch
This video shows you how to add a divider to our RecyclerView. In the first step, we make a drawable that contains a shape representing our divider with a solid colour. In the second step, we create a class called Divider that inherits from RecyclerView.ItemDecoration. We then override the onDraw method that lets us draw a horizontal divider after detecting the orientation of the LinearLayoutManager. We override the getItemOffsets method to specify spacing between the items where the divider will be drawn. We then calculate the left, top, right and bottom values for the divider and draw it for each child in the RecyclerView.