Git Product home page Git Product logo

meter-number-picker's Introduction

Meter Number Picker

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

Android Arsenal

Preview

Usage

Make sure you've added maven central to the list of your repositories at the root build.gradle:

repositories {
    mavenCentral()
}

Then add a dependency into your module's build.gradle:

dependencies {
    implementation 'com.alex-zaitsev:meternumberpicker:1.0.5'
}

Content

The library contains 2 views: MeterNumberPicker and MeterView. MeterNumberPicker is a base block for MeterView. On the screenshot above whole view is the MeterView and a single block of it is MeterNumberPicker. They are pretty simple, you can easily create your own meter class based on them.

Usage

Firstly, create a style for your number picker:

<style name="MeterNumberPickerStyle">
    <item name="mnp_min">0</item>
    <item name="mnp_max">9</item>
    <item name="mnp_textColor">@android:color/white</item>
    <item name="mnp_textSize">50sp</item>
    <item name="mnp_paddingHorizontal">5dp</item>
    <item name="mnp_paddingVertical">25dp</item>
</style>

Then, create a style for your meter view and pass the previous style:

<style name="MeterViewStyle">
    <item name="mv_firstColor">@android:color/black</item>
    <item name="mv_numberOfFirst">5</item>
    <item name="mv_numberOfSecond">1</item>
    <item name="mv_pickerStyle">@style/MeterNumberPickerStyle</item>
    <item name="mv_secondColor">@android:color/holo_red_dark</item>
</style>

Almost there! Now create your view and apply the style:

<com.alexzaitsev.meternumberpicker.MeterView
    android:id="@+id/meterView"
    style="@style/MeterViewStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

You can use MeterNumberPicker directly without MeterView wrapper. Look at the MeterView sources to catch more details.
You may also want to check the sample.

Attributes

MeterNumberPicker

attribute name attribute description
mnp_min The min value of this widget.
mnp_max The max value of this widget.
mnp_value The current value of this widget.
mnp_textColor The text color of the numbers.
mnp_textSize The text size of the numbers.
mnp_typeface The typeface of the numbers.
mnp_minWidth The min width of this widget.
mnp_minHeight The min height of this widget.
mnp_paddingHorizontal Internal horizontal padding of this widget (left/right).
mnp_paddingVertical Internal vertical padding of this widget (top/bottom).

MeterView

attribute name attribute description
mv_numberOfFirst Number of the first-placed blocks.
mv_numberOfSecond Number of the second-placed blocks.
mv_firstColor Background color for the first-placed blocks.
mv_secondColor Background color for the second-placed blocks.
mv_pickerStyle The style for the MeterNumberPicker.
mv_enabled Defines whether view reacts on clicks.

License

MeterNumberPicker is under Apache 2.0.

meter-number-picker's People

Contributors

alexzaitsev avatar bholzmayer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meter-number-picker's Issues

Animate number

Hi,

This is wonderful library I came across, I have a question regarding number scroll animation. Is there any way I can add mv.setValue(250) and it should quickly scroll animate number to 250.

I appreciate.
Thanks

How to set number from 00 to 59?

Hi Alex,

Thanks for sharing this beautiful widget! I have a question, hopes you can help me. How to set number from 00 to 59?

Just wanted to say thanks!

This is great! I needed something of this kind for a non-touch Android device (it uses an external 5 button keypad). I could modify the library with great ease for my use-case. Thanks!

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.