8.7 ItemDivider Subclass of RecyclerView.ItemDecoration

A RecyclerView.ItemDecoration object draws decorations—such as separators between items—on a RecyclerView. The RecyclerView.ItemDecoration subclass ItemDivider (Fig. 8.28) draws divider lines between list items. Lines 17–18 in the constructor obtain the predefined Android Drawable resource android.R.attr.listDivider, which is the standard Android list-item divider used by default in ListViews.

Fig. 8.28 ItemDivider subclass of RecyclerView.ItemDecoration for displaying a horizontal line between items in the RecyclerView

The code has 45 lines.

Overriding the onDrawOver Method ...

Get Android How to Program, 3/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.