Custom Android View to provide a user friendly way of picking numbers. 🧪
- Set an allowed range for users to pick.
- Provide gestures such as scrolling and long press for a better UX.
- Give haptic feedback on gestures.
- More stuff I'm planning for the future.. 📅
- You can download and try out the sample app yourself too!
- See releases to manually download AAR
For Gradle, in your project level build.gradle file:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
And then add the library in your module build.gradle:
dependencies {
implementation 'com.github.Re1r0:NumberPickerView:v1.0.1'
}
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.mirkamalg.numberpickerview.NumberPickerView
android:id="@+id/numberPickerView"
android:layout_width="0dp"
android:layout_height="60dp"
app:enableLongPressToReset="true"
app:enableSwipeGesture="true"
app:enableUserInput="true"
app:enableVibration="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="3.5:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.05"
app:maxValue="150"
app:minValue="0"
app:swipeGestureSensitivity="medium" />
</androidx.constraintlayout.widget.ConstraintLayout>
numberPickerView.setOnNumberChangedListener(object : OnNumberChangedListener {
override fun onChanged(newNumber: Int) {
Log.e("NumberPickerView", "New number: $newNumber")
}
})