Decorator
In Android, when you work with RecyclerViews, the standard way of working with paddings and margins is to work with fixed dimensions inside of the layout files.
While this works for many applications, sometimes the margins inside the layout files shouldn't be applied in every screen.
Decorator is a library that helps creating composable margins and dividers in RecyclerViews.
Install
Replace x.x.x with the latest version available
How to use
Just create one of the decorations provided in the next examples and add them to the RecyclerView using:
Margin decorations
These decorations draw a margin between the items.
LinearMarginDecoration
GridMarginDecoration
GridSpanDecoration
Divider decorations
These decorations draw a divider between the items
LinearDividerDecoration
GridDividerDecoration
Bounds margin decorations
These decorations are similar to the margin decorations,
but they only draw a margin in the bounds of the list.
LinearBoundsMarginDecoration
GridBoundsMarginDecoration
Composing decorations
If you want to apply multiple decorations, you just need to add the decorations in the correct order.
Example for a vertical RecyclerView:
You can also decide if an item at a given position should have a decoration applied: