ScrollNumber

Introduction: custom widget--srcoll number
More: Author   ReportBugs   
Tags:
动画-滚动文字-

中文 | English

A SimpleGracefulEasy-to-Use Scroll Number Widget!

Don't forget give me a star :)

Feature

  • Just need to call setNumber() could be performed.
  • You can dynamically customize number's colors、size、range、font...

image

Dependency

There are two ways:

  • clone this project, and use as dependency
  • just add following code to you build.gradle:

    compile 'top.wuhaojie:scrollnumber:1.0.0'
    

Usage

  • Add this to your layout xml file:
<top.wuhaojie.library.MultiScrollNumber
    android:id="@+id/scroll_number"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
  • Call setNumber() in your java code:
MultiScrollNumber scrollNumber = (MultiScrollNumber) findViewById(R.id.scroll_number);
scrollNumber.setNumber(2048);

Customize

  • Color Call setTextColors(@ColorRes int[] textColors) with a paramiter, a array stores colors from High bit to Low bit.
scrollNumber.setTextColors(new int[]{R.color.blue01, R.color.red01,
                R.color.green01, R.color.purple01});

image

  • Size Just call setTextSize(int textSize) with the size you want to change to, unit is sp .
scrollNumber.setTextSize(64);

image

  • Range Call setNumber(int from, int to) instead of setNumber(int val) to specify a range.
scrollNumber.setNumber(64, 2048);

image

  • Interpolator You could change interpolator with call setInterpolator(Interpolator interpolator).
scrollNumber.setInterpolator(new DecelerateInterpolator());
  • Font Change text font by call setTextFont(fileName), before this you should copy the font file to assets/ directory.
scrollNumber.setTextFont("myfont.ttf");
  • Animation Velocity Call scrollNumber.setScrollVelocity(v) to set the animation velocity, number in range of 0 ~ 1000.
scrollNumber.setScrollVelocity(30);

image

Xml

Meaning Attribute
from a number primary_number
to a number target_number
number size number_size

Update Log

  • add font change option on 22/7/2016.
  • support double or float number, setNumber(double num) 15/7/2017

License

The MIT License (MIT)

Copyright (c) 2015 WuHaojie

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Apps
About Me
GitHub: Trinea
Facebook: Dev Tools