Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nekocode/DividerDrawable
Help to layout and draw dividers on android views.
https://github.com/nekocode/DividerDrawable
android widget
Last synced: 3 months ago
JSON representation
Help to layout and draw dividers on android views.
- Host: GitHub
- URL: https://github.com/nekocode/DividerDrawable
- Owner: nekocode
- License: apache-2.0
- Created: 2017-05-12T16:13:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-18T16:39:51.000Z (over 7 years ago)
- Last Synced: 2024-06-16T03:31:47.091Z (5 months ago)
- Topics: android, widget
- Language: Java
- Homepage:
- Size: 340 KB
- Stars: 452
- Watchers: 10
- Forks: 37
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-github-android-ui - DividerDrawable - 在存在的View上布局和画分割线 (Drawable)
README
# DividerDrawable
[![Apache 2.0 License](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0.html) [![Release](https://jitpack.io/v/nekocode/DividerDrawable.svg)](https://jitpack.io/#nekocode/DividerDrawable)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
```gradle
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.
```java
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).
```java
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.
```java
DividerUtils.addDividersTo(textView, dividerDrawable);
```If you changed the divider's layout params, don't forget to notify the changes.
```java
dividerDrawable.notifyLayoutChanged();
```![Screenshot](art/screenshot.png)