【开源】TextCounter

TextCounter

使用说明:

Xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  <com.github.premnirmal.textcounter.CounterView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dp"
        android:textSize="30dp"
        android:textColor="@color/orange"
        counter:autoStart="true"
        counter:startValue="100"
        counter:endValue="5000"
        counter:incrementValue="100"
        counter:timeInterval="2"
        counter:prefix="$"
        counter:suffix=" moneys"
        counter:type="integer | decimal | both"
        />

Java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
final CounterView counterView = new CounterView(context);
counterView.setFormatter(new Formatter() {
    @Override
    public String format(String prefix, String suffix, float value) {
    return prefix 
        + NumberFormat.getNumberInstance(Locale.US).format(value) 
        + suffix;
    }
});
counterView.setAutoStart(false);
counterView.setStartValue(200f);
counterView.setEndValue(1000f);
counterView.setIncrement(5f); // the amount the number increments at each time interval
counterView.setTimeInterval(2); // the time interval (ms) at which the text changes
counterView.setPrefix("You have ");
counterView.setSuffix(" points!");
counterView.start(); // you can start anytime if autostart is set to false

posted on 2015-04-29 10:18  wasdchenhao  阅读(172)  评论(0)    收藏  举报

导航