In this article, I will talk about RecyclerView ItemDecoration and ItemAnimator and will try to explain through a simple application, which is also available at Github.

ItemDecoration (As the name suggests) should be used to decorate view items of the RecyclerView.

ItemDecoration can be used to apply dividers and other effects like padding or equal spacing among item views. To add a simple divider between item views there is a class “DividerItemDecoration” which comes with support lib above version 25.1.0. The following code snippet demonstrates its implementation:

To apply custom item decorations, the best way is to extend RecyclerView.ItemDecoration class. In the sample app, I used a GridLayoutManager and applied CharacterItemDecoration to RecyclerView:

recyclerView.addItemDecoration(new CharacterItemDecoration(50));