Giter Club home page Giter Club logo

numberpicker's Introduction

Number Picker

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

Platform Language License Android Arsenal API Download

Features

  • Customizable fonts(color, size, typeface)
  • Customizable dividers(color, distance, thickness)
  • Horizontal and Vertical mode are both supported
  • Also supports the negative values

Usage

Java

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

// set divider color
numberPicker.setDividerColor(getResources().getColor(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 text color
numberPicker.setTextColor(getResources().getColor(R.color.colorPrimary));
numberPicker.setTextColorResource(R.color.colorPrimary);

// 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);

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_textColor="@color/colorPrimary"
    app:np_textSize="@dimen/text_size"
    app:np_typeface="@string/roboto_light"
    app:np_value="3" />

Attributes

attribute name attribute description
np_width The width of this widget.
np_height The height of this widget.
np_dividerColor The color of the selection divider.
np_dividerDistance The distance between the two selection dividers.
np_dividerThickness The thickness of the selection divider.
np_formatter The formatter of the numbers.
np_max The max value of this widget.
np_min The min value of this widget.
np_orientation The orientation of this widget. Default is vertical.
np_textColor The text color of the numbers.
np_textSize The text size of the numbers.
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 {
    compile 'com.shawnlin:number-picker:2.4.2'
}

License

Copyright (C) 2016 ShawnLin013(Shawn Lin)

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.

numberpicker's People

Contributors

shawnlin013 avatar abondarew avatar

Stargazers

Thomas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.