ScrollNumber 数字滚动

ScrollNumber

项目地址: a-voyager/ScrollNumber
简介:custom widget--srcoll number

中文 | English

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...

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:

  • 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});

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

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

  • 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");

Xml

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

你可能感兴趣的:(Android,自定义控件进阶,android)