Custom Views for drawing Dotted and Dashed Lines without jumping through hoops.
Kotlin Java
Switch branches/tags
Nothing to show
Clone or download
Latest commit a7808d1 Oct 26, 2017
Permalink
Failed to load latest commit information.
app Add Copyright information Oct 24, 2017
gradle/wrapper Add Copyright information Oct 24, 2017
library Add Copyright information Oct 24, 2017
.gitignore Initial commit Oct 24, 2017
CONTRIBUTING Add CONTRIBUTING file Oct 24, 2017
LICENSE Initial commit Oct 17, 2017
NOTICE Add NOTICE file Oct 24, 2017
README.md Add Maven reference Oct 25, 2017
build.gradle Add Copyright information Oct 24, 2017
dahdit-sample.png
gradlew
gradlew.bat Initial commit Oct 24, 2017
settings.gradle Add Copyright information Oct 24, 2017

README.md

DahDit - Better Dots and Dashes in Android

Drawing a round-dotted line or a dashed line with a shape drawable in Android requires you to disable hardware rendering due to some bugs. It also doesn't play nice with wrap_content. Let's not worry about that anymore.

Usage

You can use com.xfinity.dahdit.DottedLine or com.xfinity.dahdit.DashedLine as a view in XML. By default, the line will be drawn horizontally, with dots of diameter 4dp with minimum 2dp spacing.

Spacing

The library will calculate the correct amount of spacing to add between dots in order to ensure the dots are flush to the ends of your included View.

Customizable

The View can have the dot's radius, dash's height/width, the minimum gap between dots/dashes, the color, and the orientation of the line customized in XML.

In Action

Here's what the sample app looks like if you launch it:

Demo showing appearances

Note the ImageView using wrap_content can't be seen at all. Meanwhile, all the dashed and dotted lines fit nicely, and flush their dots/dashes to the edge of their view.

Using DahDit

DahDit is available on MavenCentral. To use DahDit, in your project build.gradle add

compile 'com.xfinity:dahdit:0.9.3'