Skip to content

🚀 Custom view for Android which provides a modern design and gestures for picking numbers in a user friendly way.

Notifications You must be signed in to change notification settings

mirkamalg/NumberPickerView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NumberPickerView

Custom Android View to provide a user friendly way of picking numbers. 🧪

Features

  • 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.. 📅

Sample app

  • Sample
  • You can download and try out the sample app yourself too!

Usage

Dependency

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'
	}

Add the view to your layout

<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>

Listen for changes

numberPickerView.setOnNumberChangedListener(object : OnNumberChangedListener {
            override fun onChanged(newNumber: Int) {
                Log.e("NumberPickerView", "New number: $newNumber")
            }

        })

License

GNU Lesser General Public License v3.0

About

🚀 Custom view for Android which provides a modern design and gestures for picking numbers in a user friendly way.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages