Home

Awesome

DividerDrawable

Apache 2.0 License Release

This library can help you easily layout and draw dividers on existing views. For better performance, don't create new views for drawing dividers anymore, use drawable instead.

Install

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
    compile 'com.github.nekocode:DividerDrawable:{lastest-version}'
}

Usage

Obtain a new DividerDrawable instance. And you can set the color and stroke witdh of the divider.

final DividerDrawable dividerDrawable = new DividerDrawable();
dividerDrawable.setStrokeWidth(10)
        .setColor(0xFFFFFFFF)

Similar to the view layout, the DividerDrawable also has a layout that can help draw divider to the relative position of the container(view/drawable/canvas).

dividerDrawable.getLayout()
        .setOrientation(DividerLayout.ORIENTATION_VERTICAL)
        .setAlign(DividerLayout.ALIGN_PARENT_BOTTOM)
        .setCenter(DividerLayout.CENTER_HORIZONTAL)
        .setMarginBottomDp(20);

You can use DividerUtils to easily combine the divider drawable to your existing backgroud drawable.

DividerUtils.addDividersTo(textView, dividerDrawable);

If you changed the divider's layout params, don't forget to notify the changes.

dividerDrawable.notifyLayoutChanged();

Screenshot