Android scrolling ruler view
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'
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"/>
Add a scroll listener to get the value on scroll:
ruller.scrollListener = object: ScrollRulerListener {
override fun onRulerScrolled(value: Float) {
//...
}
}
Set the minimum value, maximum value, and initial value through code:
ruller.reload(min = 50f, max = 250f, initValue = 180f)
ruller.scrollToValue(value = 123f)