源码分享:仿余额宝数字跳动效果 TextCounter

时间:2022-04-27
本文章向大家介绍源码分享:仿余额宝数字跳动效果 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

4、TextCounter 下载


原文链接:仿余额宝数字跳动效果 TextCounter,(http://apkdemo.com/textcounter.html)转发请注明来源!