Skip to content

myDario/DarioScrollRuler

Repository files navigation

DarioScrollRuler

Android scrolling ruler view

Install Dependency

If you haven't already, add the jitpack repository to the root buil.gradle file.

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

Add the dependency:

implementation 'com.github.myDario:DarioScrollRuler:1.0.8'

Usage

Add the view in a layout:

<com.labstyle.darioscrollruler.DarioScrollRuler
    android:id="@+id/darioScrollRuler"
    app:minValue="100"
    app:maxValue="300"
    app:initialValue="200"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"/>

Scroll listener

Add a scroll listener to get the value on scroll:

ruller.scrollListener = object: ScrollRulerListener {
    override fun onRulerScrolled(value: Float) {
        //...
    }
}

Set min, max, initial value

Set the minimum value, maximum value, and initial value through code:

ruller.reload(min = 50f, max = 250f, initValue = 180f)

Scroll to a value

ruller.scrollToValue(value = 123f)