Dividers
Dividers is an Android library to easily create separators for your RecyclerViews. It supports a wide range of dividers from simple ones, that apply to all your items equally, to a system of selectors that apply different styles to each item.

Usage
The easiest way to start using Dividers
is to create a DividerItemDecoration
with a layer and provide it to your RecyclerView
as follows:
If you want to use all the features of Dividers
follow these steps:
- Create a collection of instances of
Layer
with the help ofLayersBuilder
to define the drawables you want to apply. EachLayer
is composed of: - An implementation of the
Selector
interface, defining which items are going to be affected by the layer. You can use one of the multiple implementations that come in the library or create your own.
- An instance of
Divider
, containing the drawable that is going to be used to render the separator. Create them using theDividerBuilder
class.
- Finally, create a collection of
Layer
instances with the help ofLayersBuilder
- Create a new instance of
DividerItemDecoration
with your newly created layers.
- Add your
DividerItemDecoration
to yourRecyclerView
using theaddItemDecoration
method.
Selectors
Selectors give you the possibility to apply different configurations to a fixed set of items of your view. There are multiple implementations to apply the same separator to every item in a single row (AllItemsInRowSelector
) or column (AllItemsInColumnSelector
).
For example, to show the divider in all the elements except the header you can use the following snippet:
You can also create your own Selector to apply dividers to all items but the ones in the header:
As you have seen, selectors also let you apply a divider to some sides of every item depending on things such as the position. In this way you can create selectors to display items as a whole, you can take a look at some examples like RowGroupSelector
:
Dividers
Dividers are the smallest components that can be rendered and represent all the separators for a single cell. Internally, dividers are represented as a grid of 3x3 elements (ignoring the center). Each side can be referenced with a value from the enum Direction
. This can prove useful when defining complex dividers such as the ones used in headers or footers.
Add it to your project
Add Dividers
dependency to your build.gradle
file
or to your pom.xml
if you are using Maven instead of Gradle