• Stars
    star
    381
  • Rank 112,502 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android custom view that uses ruler for picking the number from given range.

Android Ruler Picker

Build Status API Javadoc

Android custom view that uses ruler for picking the number from given range.

Features:

  • Easy to integrate. All you have to do is add the view into your XML and listen for the value changes.
  • Highly customizable. Change width, height, color, distance between indicators. Change the color and sze of the texts in the ruler in XML or dynamically from your java or kotlin code.
  • Extremely lightweight πŸ‹.

How to use this library?

  • Gradle dependency:

    • Add below dependency into your build.gradle file.
      compile 'com.kevalpatel2106:ruler-picker:1.1'
    • For other build systems see Import.md.
  • Add RulerValuePicker inside your XML layout.

<com.kevalpatel2106.rulerpicker.RulerValuePicker
    android:id="@+id/ruler_picker"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:background="@android:color/holo_orange_dark"
    app:indicator_color="@android:color/white"
    app:indicator_interval="14dp"
    app:indicator_width="2dp"
    app:max_value="120"
    app:min_value="35"
    app:notch_color="@android:color/white"
    app:ruler_text_size="6sp"/>
  • Library provides XML attributes to customize the RulerValuePicker or you can customize it dynamically using Java/Kotlin code.
Attribute Type Java/Kotlin Description
indicator_color Color setIndicatorColor() Change the color of the indicator in the ruler.
indicator_interval Dimensions setIndicatorIntervalDistance() Change the distance between two indicators in the ruler.
indicator_width Dimensions setIndicatorWidth() Change the width (thickness) of the indicator.
notch_color Color setNotchColor() Change the color off the notch at the top of the ruler.
ruler_text_size Dimensions setTextSize() Change the size of the text that displays the values in the ruler.
ruler_text_color Color setTextColor() Change the color of the text that displays the values in the ruler.
long_height_height_ratio Fraction setIndicatorHeight() Change the height of the long indicator. The value is between 0 to 1 where 1 indicates the height of the ruler. This value must be greater than or equal to long_height_height_ratio.
short_height_height_ratio Fraction setIndicatorHeight() Change the height of the short indicator. The value is between 0 to 1 where 1 indicates the height of the ruler. This value must be less than or equal to short_height_height_ratio.
max_value Integer setMinMaxValue() Maximum possible value to display in the ruler. This value must be greater than min_value.
min_value Integer setMinMaxValue() Minimum possible value to display in the ruler. This value must be greater than max_value.
  • Set the initially selected value.
rulerValuePicker.selectValue(55 /* Initial value */);
  • Set up a RulerValuePickerListener callback listener to get notify when the selected value changes. Application will receive the final selected value in onValueChange() callback.

Java:

rulerValuePicker.setValuePickerListener(new RulerValuePickerListener() {
    @Override
    public void onValueChange(final int selectedValue) {
        //Value changed and the user stopped scrolling the ruler.
        //Application can consider this value as final selected value.
    }

    @Override
    public void onIntermediateValueChange(final int selectedValue) {
        //Value changed but the user is still scrolling the ruler.
        //This value is not final value. Application can utilize this value to display the current selected value.
    }
});

Kotlin:

rulerValuePicker.setValuePickerListener(object : RulerValuePickerListener {
    override fun onValueChange(value: Int) {
        //Value changed and the user stopped scrolling the ruler.
        //You can consider this value as final selected value.
    }

    override fun onIntermediateValueChange(selectedValue: Int) {
        //Value changed but the user is still scrolling the ruler.
        //This value is not final value. You can utilize this value to display the current selected value.
    }
})

Screenshots:

Sample 1 Sample 2
profile-demo.gif ruler-view-demo.gif

What to try this out?

  • You can download the sample apk from here and play with it.

Want to contribute?

Every small or large contribution to this project is appreciated. Make sure you read the contribution guide before generating the pull request.

Questions?πŸ€”

Hit me on twitter Twitter

Acknowledgements:

License

Copyright 2018 Keval Patel

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

android-hidden-camera

This library is to take picture using camera without camera preview.
Java
396
star
2

EmoticonGIFKeyboard

An advance Emoticons & GIF keyboard.
Java
273
star
3

PasscodeView

PasscodeView is an Android Library to easily and securely authenticate user with PIN code or using the fingerprint scanner.
Java
272
star
4

android-samples

Repository that contains android tutorial projects and sample applications
Java
229
star
5

Prevent-Screen-Off

This is the library that keeps the screen on until user is looking at the screen.
Java
176
star
6

FingerprintDialogCompat

FingerprintDialog from Android 28 (P) back ported to Android 23 (M).
Java
104
star
7

android-ringtone-picker

Simple Ringtone Picker dialog which allows you to pick different sounds from ringtone, alarm tone, notification tone and music from external storage.
Java
74
star
8

green-build

An android app for managing your CI builds.
Kotlin
73
star
9

UserAwareVideoView

A customized video view that will automatically pause video is user is not looking at device screen!!!!!
Java
51
star
10

Open-Weather-API-Wrapper

An Android wrapper for the APIs of https://openweathermap.org
Java
22
star
11

remote-storage-android-things

Create an FTP server using on raspberry pi and build your own wireless storage & backup solution for home.
Java
20
star
12

year-in-progress

Deadline tracker
Kotlin
17
star
13

PastryShop

Take home task for the cookpad interview (Sr. Android Engineer) 2018
Kotlin
15
star
14

smart-lens

Get the information of object based on image recognition using TensorFlow.
Java
12
star
15

unity-lamborghini-car

See Lamborghini in the real world.
C#
12
star
16

unity-snake-game

This is smaple 2D unity snake game.
C#
12
star
17

collision-detector-android-things

Get the distance of the object using Android Things & ultrasonic ranging sensor HC-SR04.
Java
10
star
18

pocket-ci

Check your builds from your pocket
Kotlin
9
star
19

smartswitch

Control your home switches remotely from phone using Android Things.
Java
9
star
20

torrent-downloader-android-things

Java
7
star
21

github-issue-cloud-function

πŸ”₯ Firebase cloud function to post a GitHub issue whenever new crash🐞 reported in firebase crashalytics.
JavaScript
7
star
22

rxbus

Implementation of event bus using Rx for Android.
Java
5
star
23

remote-bluetooth-speaker-android-things

Java
5
star
24

Currency-Converter-App

Currency converter android app
Kotlin
4
star
25

robo-car

Java
4
star
26

crypto-wallet

Demo application for displaying the Bitcoin transaction in Crypto Wallet.
Kotlin
3
star
27

gitlab-ci-android

GitLab CI Docker image to create android builds.
Shell
3
star
28

basic-android

A ready to start from scratch setup for android application project
Java
3
star
29

Github-User-Search

Java
3
star
30

vuforia-barcode-scanner

A barcode scanner for Vuforia based AR applications.
C#
2
star
31

google-home-andorid-things

Protocol Buffer
2
star
32

Stand-Up

Sitting is next cancer.
Kotlin
2
star
33

brew

Kotlin
2
star
34

kevalpatel2106.github.io

Source code for my personal website.
SCSS
2
star
35

rpi-setup

This script will set up your raspberry pi after first boot.
Shell
1
star
36

kevalpatel2106

1
star
37

ar-solar-system

Augmented reality specific model of the solar system using unity in ARCore.
C#
1
star
38

SpinWheelView

Java
1
star
39

home

Java
1
star