All Projects → ShawnLin013 → Numberpicker

ShawnLin013 / Numberpicker

Licence: mit
🎰 The android library that provides a simple and customizable NumberPicker.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Numberpicker

Android Arsenal.com
Source to android-arsenal.herokuapp.com
Stars: ✭ 541 (-29.37%)
Mutual labels:  android-ui
Audio Visualizer Android
🎵 [Android Library] A light-weight and easy-to-use Audio Visualizer for Android.
Stars: ✭ 581 (-24.15%)
Mutual labels:  android-ui
Zoomrecylerlayout
🎢 Zoom Recycler Layout Manager For Android Kotlin
Stars: ✭ 618 (-19.32%)
Mutual labels:  android-ui
Superbottomsheet
Android native BottomSheet on steroids 💪
Stars: ✭ 548 (-28.46%)
Mutual labels:  android-ui
Alerter
An Android Alerting Library
Stars: ✭ 5,213 (+580.55%)
Mutual labels:  android-ui
Materialfavoritebutton
Animated favorite/star/like button
Stars: ✭ 586 (-23.5%)
Mutual labels:  android-ui
Materialdrawerkt
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library.
Stars: ✭ 508 (-33.68%)
Mutual labels:  android-ui
Music Player Go
🎶🎼 Very slim music player 👨‍🎤 100% made in Italy 🍕🌳🌞🍝🌄
Stars: ✭ 654 (-14.62%)
Mutual labels:  android-ui
Androidrapidlibrary
Android 快速开发库,主要想实现一条属于自己的开发框架。包括网络访问,数据,UI等等
Stars: ✭ 577 (-24.67%)
Mutual labels:  android-ui
Materialdialog Android
📱Android Library to implement animated, 😍beautiful, 🎨stylish Material Dialog in android apps easily.
Stars: ✭ 602 (-21.41%)
Mutual labels:  android-ui
Fabrevealmenu Master
A general purpose android UI library to show a user show menu in accordance of Floating action button with material design guidelines.
Stars: ✭ 558 (-27.15%)
Mutual labels:  android-ui
My flutter challenges
Flutter project containing all my flutter UI challenges
Stars: ✭ 563 (-26.5%)
Mutual labels:  android-ui
Guidetocustomviews
The ultimate guide to Android custom views
Stars: ✭ 595 (-22.32%)
Mutual labels:  android-ui
Smartrefreshlayout
🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。
Stars: ✭ 23,185 (+2926.76%)
Mutual labels:  android-ui
Androidscreenadaptation
A light and easy-to-use Android development screen adaptation tool library(一个轻量好用的安卓开发屏幕适配工具库)
Stars: ✭ 619 (-19.19%)
Mutual labels:  android-ui
Imaging
Android Image Edit Lib. Android 图片编辑库,微信图片编辑库
Stars: ✭ 531 (-30.68%)
Mutual labels:  android-ui
Android Material Design For Pre Lollipop
Various UI implementations, animations & effects based on Material Design compatible with pre Lollipop devices as well. (Work in progess)
Stars: ✭ 585 (-23.63%)
Mutual labels:  android-ui
Codeview Android
Display code with syntax highlighting ✨ in native way.
Stars: ✭ 748 (-2.35%)
Mutual labels:  android-ui
Discretescrollview
A scrollable list of items that centers the current element and provides easy-to-use APIs for cool item animations.
Stars: ✭ 5,533 (+622.32%)
Mutual labels:  android-ui
Bubble Scroll
An animating scroll bar
Stars: ✭ 598 (-21.93%)
Mutual labels:  android-ui

Number Picker

The android library that provides a simple and customizable NumberPicker. It's based on android.widget.NumberPicker.

Platform Language Android Arsenal API Download CircleCI

Features

  • Customizable fonts(color, size, strikethrough, underline, typeface)
  • Customizable dividers(color, distance, length, thickness, type)
  • Horizontal and Vertical mode are both supported
  • Ascending and Descending order are both supported
  • Also supports negative values and multiple lines

Usage

Java

NumberPicker numberPicker = (NumberPicker) findViewById(R.id.number_picker);

// Set divider color
numberPicker.setDividerColor(ContextCompat.getColor(this, R.color.colorPrimary));
numberPicker.setDividerColorResource(R.color.colorPrimary);

// Set formatter
numberPicker.setFormatter(getString(R.string.number_picker_formatter));
numberPicker.setFormatter(R.string.number_picker_formatter);

// Set selected text color
numberPicker.setSelectedTextColor(ContextCompat.getColor(this, R.color.colorPrimary));
numberPicker.setSelectedTextColorResource(R.color.colorPrimary);

// Set selected text size
numberPicker.setSelectedTextSize(getResources().getDimension(R.dimen.selected_text_size));
numberPicker.setSelectedTextSize(R.dimen.selected_text_size);

// Set selected typeface
numberPicker.setSelectedTypeface(Typeface.create(getString(R.string.roboto_light), Typeface.NORMAL));
numberPicker.setSelectedTypeface(getString(R.string.roboto_light), Typeface.NORMAL);
numberPicker.setSelectedTypeface(getString(R.string.roboto_light));
numberPicker.setSelectedTypeface(R.string.roboto_light, Typeface.NORMAL);
numberPicker.setSelectedTypeface(R.string.roboto_light);

// Set text color
numberPicker.setTextColor(ContextCompat.getColor(this, R.color.dark_grey));
numberPicker.setTextColorResource(R.color.dark_grey);

// Set text size
numberPicker.setTextSize(getResources().getDimension(R.dimen.text_size));
numberPicker.setTextSize(R.dimen.text_size);

// Set typeface
numberPicker.setTypeface(Typeface.create(getString(R.string.roboto_light), Typeface.NORMAL));
numberPicker.setTypeface(getString(R.string.roboto_light), Typeface.NORMAL);
numberPicker.setTypeface(getString(R.string.roboto_light));
numberPicker.setTypeface(R.string.roboto_light, Typeface.NORMAL);
numberPicker.setTypeface(R.string.roboto_light);

// Set value
numberPicker.setMaxValue(59);
numberPicker.setMinValue(0);
numberPicker.setValue(3);

// Using string values
// IMPORTANT! setMinValue to 1 and call setDisplayedValues after setMinValue and setMaxValue
String[] data = {"A", "B", "C", "D", "E", "F", "G", "H", "I"};
numberPicker.setMinValue(1);
numberPicker.setMaxValue(data.length);
numberPicker.setDisplayedValues(data);
numberPicker.setValue(7);

// Set fading edge enabled
numberPicker.setFadingEdgeEnabled(true);

// Set scroller enabled
numberPicker.setScrollerEnabled(true);

// Set wrap selector wheel
numberPicker.setWrapSelectorWheel(true);

// Set accessibility description enabled
numberPicker.setAccessibilityDescriptionEnabled(true);
        
// OnClickListener
numberPicker.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Log.d(TAG, "Click on current value");
    }
});

// OnValueChangeListener
numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
    @Override
    public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
        Log.d(TAG, String.format(Locale.US, "oldVal: %d, newVal: %d", oldVal, newVal));
    }
});

// OnScrollListener
numberPicker.setOnScrollListener(new NumberPicker.OnScrollListener() {
    @Override
    public void onScrollStateChange(NumberPicker picker, int scrollState) {
        if (scrollState == SCROLL_STATE_IDLE) {
            Log.d(TAG, String.format(Locale.US, "newVal: %d", picker.getValue()));
        }
    }
});

XML

add xmlns:app="http://schemas.android.com/apk/res-auto"

<com.shawnlin.numberpicker.NumberPicker
    android:id="@+id/number_picker"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    app:np_width="64dp"
    app:np_height="180dp"
    app:np_dividerColor="@color/colorPrimary"
    app:np_formatter="@string/number_picker_formatter"
    app:np_max="59"
    app:np_min="0"
    app:np_selectedTextColor="@color/colorPrimary"
    app:np_selectedTextSize="@dimen/selected_text_size"
    app:np_textColor="@color/colorPrimary"
    app:np_textSize="@dimen/text_size"
    app:np_typeface="@string/roboto_light"
    app:np_value="3" />

Attributes

attribute name attribute description defalut
np_width The width of this widget.
np_height The height of this widget.
np_accessibilityDescriptionEnabled Flag whether the accessibility description enabled. enabled
np_dividerColor The color of the selection divider.
np_dividerDistance The distance between the two selection dividers.
np_dividerLength The length of the selection divider.
np_dividerThickness The thickness of the selection divider.
np_dividerType The type of the selection divider. side_lines
np_fadingEdgeEnabled Flag whether the fading edge should enabled.
np_fadingEdgeStrength The strength of fading edge while drawing the selector.
np_formatter The formatter of the numbers.
np_hideWheelUntilFocused Flag whether the selector wheel should hidden until the picker has focus.
np_itemSpacing Amount of space between items.
np_lineSpacingMultiplier The line spacing multiplier for the multiple lines.
np_max The max value of this widget.
np_maxFlingVelocityCoefficient The coefficient to adjust (divide) the max fling velocity.
np_min The min value of this widget.
np_order The order of this widget. ascending
np_orientation The orientation of this widget. vertical
np_scrollerEnabled Flag whether the scroller should enabled.
np_selectedTextAlign The text align of the selected number. center
np_selectedTextColor The text color of the selected number.
np_selectedTextSize The text size of the selected number.
np_selectedTextStrikeThru Flag whether the selected text should strikethroughed.
np_selectedTextUnderline Flag whether the selected text should underlined.
np_selectedTypeface The typeface of the selected numbers.
np_textAlign The text align of the numbers. center
np_textColor The text color of the numbers.
np_textSize The text size of the numbers.
np_textStrikeThru Flag whether the text should strikethroughed.
np_textUnderline Flag whether the text should underlined.
np_typeface The typeface of the numbers.
np_value The current value of this widget.
np_wheelItemCount The number of items show in the selector wheel.
np_wrapSelectorWheel Flag whether the selector should wrap around.

Gradle

Add the dependency in your build.gradle

buildscript {
    repositories {
        jcenter()
    }
}

dependencies {
    implementation 'com.shawnlin:number-picker:2.4.12'
}

Support

Thank you to all our backers! 🙏

Buy Me a Coffee at ko-fi.com

License

The source code is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].