The easiest way to create a dashed or striped background on Android 🐝

Overview

DashedView

The easiest way to create a dashed or striped background on Android

ktlint

The DashedView library allows you to create views with a dashed (or striped) background. Below are some examples of views created with this library. You can click on any example to see its code.

Screen Shot 2021-05-21 at 11 42 53 PM Screen Shot 2021-05-21 at 11 42 18 PM
card1 card2

There is also a demo app for this library which allows you to see the look and feel of the DashedView on your own device:

Get it on Google Play

Quick Start Guide

If you don't have this already, add it to your root build.gradle file:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Then you can add the dependency to your app build.gradle file:

dependencies {
    ...
    implementation 'com.github.MackHartley:DashedView:1.0.0'
}

Once that's finished you can declare a DashedView via XML:

<com.mackhartley.dashedview.DashedView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:dvDashAngle="45"
    app:dvDashColor="#777"
    app:dvDashWidth="4dp"
    app:dvSpaceBetweenDashes="4dp"
    app:dvViewCornerRadius="0dp" />

Usage ⚙️

The table below explains the 5 XML attributes you can set on the DashedView class:

XML Attribute Use
dvDashAngle Sets the angle of the dashes. The angle is measured from the X axis of the view.
dvDashColor Sets the color of the dashes.
dvDashWidth Sets the width of the dashes.
dvSpaceBetweenDashes Sets the width of the space between each dash.
dvViewCornerRadius Sets the corner radius value for the DashedView. Useful when working with other views that have rounded corners.

The DashedView also has a public method that allows you to set custom coloring for individual dashes:

Public Method Use
setDashColorGenerator(...) This method takes a DashColorGenerator instance as a parameter which gives you access to the index of the current dash being drawn. Using that information you can specify logic for how each dash should be colored.
interface DashColorGenerator {
    @ColorInt fun getPaintColor(curIndex: Int, numDashes: Int): Int
}

To see an example of the DashColorGenerator click here.

More Examples 🖼️

heropic hero2 Screen Shot 2021-05-21 at 11 44 19 PM Screen Shot 2021-05-23 at 3 48 04 PM
Screen Shot 2021-05-23 at 3 47 38 PM

Contributing 🤝

Feel free to open issues on this repo to report bugs or request features. Additionally if you'd like to contribute you can create a pull request (make sure to read contributing.mk).

Special thanks to all those who have supported this repo thus far!



License 📄

Copyright 2021 Mack Hartley

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

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...
A general purpose kotlin library that use kotlin coroutines, flows and channels to provide timer features with the most easy and efficient way

Timer Timer is a general purpose kotlin library that use kotlin coroutines, flows and channels to provide timer features with the most easy and effici

This console based application calculates sales tax, import duty and provide a way to print the invoice

Sales Tax Problem This console based application calculates sales tax, import du

Eurosport - Clean architecture MVVM (Modern way)
Eurosport - Clean architecture MVVM (Modern way)

eurosport Copyright 2022 by Youssef Mourchid clean architecture MVVM (Modern way

Poc-sealed-secrets - An alternative to store sensitive data in the template Secrets Kubernetes an encrypted way

POC Sealed Secrets Overview Proof of concept with the objective of showing an al

Photon Framework provides cool way to Discord Slash Commands 👩‍💻 🚧

Photon Framework provides cool way to Discord Slash Commands 👩‍💻 🚧

Terror Cellar Android app create using Kotlin
Terror Cellar Android app create using Kotlin

Terror_Cellar Technologies Used Kotlin, Firebase (authentication), Room ORM (database) About the Project This was the main project of a Mobile Computi

A android application to create personalise movie list

WatchBox An android app to create personalize list of Movie or TvSeries API Free API is used from https://www.omdbapi.com/ to fetch movie list Archite

Create Android Demo with TCP/IP Protocol.

DEMO说明文档 本demo为Java 编写的给Android手机或平板使用TCP方式控制Dobot协作机器人CR(以下简称CR)的DEMO DEMO系统要求 Android 4.3版本以上即可 工程文件说明 工程文件需要使用Android Studio打开,请使用4.0版本的Android Stu

Releases(1.0.0)
Owner
Sometimes my side projects spawn their own side projects. When that happens I post about it here.
null
A simple Android app to demonstrate the use of Hover SDK for M-PESA Send Money while offline. This SDK does not require an internet connection, it automates USSD sessions in the background of an android application.

HoverSDKDemo Hover SDK is an Android SDK that lets mobile developers to add money features to the applications. This SDK does not require an internet

Joel Kanyi 9 Dec 21, 2022
PDFER - App demo that uses WorkManager API to download and schedule PDFs in the background

PDFER App demo that uses WorkManager API to download and schedule PDFs in the background Download PDF You can either download custom pdf files by plac

Ahmed Samir 4 Nov 22, 2022
An App based on MVVM architecture to track & store a user's runs using Google Maps, with options to view & sort the runs as per the user's choice along the with option to run the app in background.

An App based on MVVM architecture to track & store a user's runs using Google Maps, with options to view & sort the runs as per the user's choice along the with option to run the app in background.

Harshit Maheshwari 1 Jun 9, 2022
This Android app shows bus connections from Koleje Strahov station to Dejvická station and the other way in the city of Prague

This Android app shows bus connections from Koleje Strahov station to Dejvická station and the other way in the city of Prague. These are important for many students from the Czech Technical University in Prague.

Lašťa Apps 3 Jul 28, 2022
Modern Android Development - The Freeletics way

Modern Android Development - The Freeletics Way At Freeletics use many of the Jetpack/AndroidX libraries but we don't always use them in the way they

Freeletics 60 Dec 14, 2022
Shot is an Android project you can use to write screenshot for your apps in a simple and friendly way

Shot is an Android project you can use to write screenshot for your apps in a simple and friendly way. What is this? Shot is a Gradle plugin and

Pedro Gómez 1k Dec 30, 2022
An Android app to stream and download your media stored in Google Drive in an Awesome way !!

⚡ Thunder : An Android app to stream and download your media stored in Google Drive in an Awesome way !! (Just Movies for now) ?? Getting Started : Le

null 278 Jan 5, 2023
The easy way to use biometric authentication in your Flutter app. Supports Fingerprint, FaceID and Iris.

BiometricX The easy way to use biometric authentication in your Flutter app. Supports Fingerprint, FaceID and Iris. Demo APK. Starting $ flutter pub a

Salman S 13 Dec 15, 2022
Experience Minecraft in a different way

tesseract Experience Minecraft in a different way. Tesseract is a server software for Minecraft: Bedrock Edition. But it uses a different concept then

Kevin Ludwig 15 Dec 17, 2022
Olalekan Fagbemi 0 Nov 7, 2021