Android library providing simple way to control divider items (ItemDecoration) of RecyclerView

Min SDK   9
Latest Commit   2016-07-01 10:33:11
License   Apache-2.0




Using app client to scan QR code to run Demo


CyberAgent, Inc.
Yokohama, Japan


PopupListView An android powerful listview,which item in listview can be click and popup show inner view under item view
FlabbyListView Android library to display a ListView whose cells are not rigid but flabby and react to ListView scroll.
NestRefreshLayout pull-to-refresh layout implements NestedScrollingParent NestedScrollingChild


Android Arsenal License Download

Android library providing simple way to control divider items of RecyclerView

Simple Divider Complex Divider

Release Note

[Release Note] (


repositories {

dependencies {
    compile 'com.yqritc:recyclerview-flexibledivider:1.4.0'


The following is the simplest usage.
Drawing a divider drawable retrieved from android.R.attr.listDivider between each cell.

RecyclerView recyclerView = (RecyclerView) findViewById(;
recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).build());
ItemDecoration Usage
HorizontalDividerItemDecoration For layout manager having vertical orientation to draw horizontal divider
VerticalDividerItemDecoration For layout manager having horizontal orientation to draw vertical divider
*Please note that you can only set one of above item decorations at a time.

If you want to set color, size and margin values, you can specify as the followings.

RecyclerView recyclerView = (RecyclerView) findViewById(;
        new HorizontalDividerItemDecoration.Builder(this)
                .marginResId(R.dimen.leftmargin, R.dimen.rightmargin)

Instead of setting color and size, you can set paint object.

Paint paint = new Paint();
paint.setPathEffect(new DashPathEffect(new float[]{25.0f, 25.0f}, 0));
        new HorizontalDividerItemDecoration.Builder(this).paint(paint).build());

Also 9patch drawable can be used for drawing divider.

RecyclerView recyclerView = (RecyclerView) findViewById(;
recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this)

If you want to customize divider depending on the position, implement the following interfaces.

List of provider

The following providers can be implemented and controllable for each divider drawn between cells.
Please refer to ComplexAdapter class in the sample for the usage of providers in detail.

  • ColorProvider Provide color for divider

  • PaintProvider Provide paint object for divider line to draw.

  • DrawableDivider Provide drawable object for divider line

  • SizeProvider Provide height for horizontal divider, width for vertical divider.

  • VisibilityProvider
    Enables you to control the visibility of dividers.

  • MarginProvider for horizontal divider (vertical list)
    Enables you to specify left and right margin of divider.

  • MarginProvider for vertical divider (horizontal list)
    Enables you to specify top and bottom margin of divider.

For GridLayoutManager, the position parameter of above providers is group index of items. So, control your divider based on [group index](, int)) instead of the position of items.


  • Builder.showLastDivider
    Draw divider line at the end of last item in RecyclerView. If you enable this, the range of position parameter of providers listed above is 0 to itemCount-1. Otherwise, the range is 0 to itemCount-2.

  • Builder.positionInsideItem
    Draw divider inside items.
    If you want to follow material design guideline, enable this feature.


  • When neither of color, paint, drawable is set, default divider retrieved from android.R.attr.listDivider will be used.
  • When you set Paint, you must use setColor and setStrokeWidth methods of paint class.
  • If you want to use DashPathEffect, please note the following issue.
Looking for custom ItemDecoration to achieve equal column space for GridLayoutManager?

Check out


Copyright 2016 yqritc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.