Gauge-Library-Android

A custom gauge library for Android, where developers can easily implement meters and gauges in XML UI. This library is written in Kotlin and is inspired by and forked from the discontinued CustomGauge, a Java library that was previously hosted on JCenter.

Features

Installation

Step 1: Add the JitPack repository to your build file

In your root build.gradle file, add the following at the end of the repositories section:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

Step 2: Add the dependency

Add the following dependency to your module-level build.gradle file:

dependencies {
implementation 'com.github.codersalman:Gauge-Library-Android:0.0.1'
}

Add the following dependency to your module-level build.gradle.kts file:

    dependencies {
        implementation("com.github.codersalman:Gauge-Library-Android:0.0.1")
    }

Attributes

Available View Attributes

The following attributes can be used to customize the gauge view in your Android project:

These attributes give you full control over the appearance and behavior of the gauge in your layout.

Kotlin

Add the following Kotlin code to your activity file:

private var gauge: Gauge? = null

val gauge = findViewById<Gauge>(R.id.gauge1)

gauge?.apply {
    sweepAngle = 270

}

XML

Add the following XML code to your layout file:

 <com.imsalman.gaugelibrary.Gauge
        android:id="@+id/gauge1"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:paddingBottom="20dp"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="20dp"
        android:layout_marginTop="160dp"
        android:layout_gravity="center"
        app:gaugePointStartColor="#4CAF50"
        app:gaugePointEndColor="#00ff00"
        app:gaugePointSize="89"
        app:gaugeStartAngle="135"
        app:gaugeStrokeCap="ROUND"
        app:gaugeStrokeColor="#FF367A"
        app:gaugeStrokeWidth="10dp"
        app:gaugeStartValue="0"
        app:gaugeEndValue="1000"
        app:gaugeSweepAngle="270"
        />

Screenshots

img.png

License

MIT License
This project is licensed under the MIT License. See the LICENSE file for details.