仿余额宝数字跳动效果 TextCounter

1、TextCounter 效果


 


 

2、TextCounter 说明


 

每次打开余额宝第一件事情就去看看有多少钱,最炫的就是看着钱在跳动相当的舒服,今天放出这个效果。

 

 

温馨提示:支持的Android版本最低的是Android 4.0.0 IceCreamSandwich ( API等级14 )

 

3、TextCounter 使用


 

例子列表:

Xml 中的使用方法

Java 中的使用方法

 

Xml 中的使用方法:

 

<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 中的使用方法:

 

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 2016-01-06 10:16  Android搬砖工  阅读(1252)  评论(0编辑  收藏  举报

导航