Skip to content

Indicator like tachometer View Library for Android

License

Notifications You must be signed in to change notification settings

Naaatan/Tachometer

Repository files navigation

Tachometer Android

Indicator like tachometer View Library for Android

GIF

Sample Preview

Setup

Step 1. Add Jitpack repository to your project build.gradle

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

Step 2. Add dependency to your app build.gradle

dependencies {
    implementation 'com.github.Naaatan:Tachometer:1.1.0'
}

Layout

<nay.lib.Tachometer
    android:id="@+id/tachometer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:max="100"
    app:min="0"
    app:borderSize="8dp"
    app:borderColor="#4B3453"
    app:fillColor="#FF01D9C2"
    app:metricText="km/h"
    app:metricTextSize="20sp"
    app:valueTextSize="60sp"
    app:textColor="#FF01D9C2"
    app:textGap="24dp"
    app:textOverColor="#F44336"
    app:textUnderColor="#03A9F4"
    app:tick_split_major="7"
    app:tick_split_minor="5"/>

Usage

tachometer.setMeterValue(v = value, d = 1000L) {
    // called when the animation ends
    // your code...
}

Value Formatter

tachometer.setValueFormatter { value ->
    value.toString(radix = 16)
}

Example

Look at the sample code