Sign in Go Pro

RecyclerView

Using ItemDecoration to Add Dividers to a List

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next

Previous

About

In this video I am going show how to add dividers between your list items. To add dividers, we will use a facility built into RecyclerView named [ItemDecoration](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemDecoration.html), which is a special class that allows the application to draw offsets and drawables onto a RecyclerView. ####Lesson Objectives * Add list dividers to RecylerView that uses Linear, Grid, and StaggaredGrid Layout Managers * Show how to write and use a custom ItemDecoration class * Explain how\when to use ItemDecoration methods: onDraw(), onDrawOver(), and getItemOffsets() * Proper way to access adapter information from class (using getChildAdapterPosition()) * Using CardView for variably sized content ####Material Design Reference for Divider Usage There is excellent guidance about using [lists](https://material.io/guidelines/components/lists.html) that is worth reading. The information about using [cards](https://material.io/guidelines/components/cards.html) is particularly relevant to this lesson. #### Android References [ItemDecoration](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemDecoration.html) [DividerItemDecoration](https://developer.android.com/reference/android/support/v7/widget/DividerItemDecoration.html) [CardView](https://developer.android.com/reference/android/support/v7/widget/CardView.html)

Lessons in RecyclerView