ValueAnimator --数值发生器,可以实现很多很灵活的动画效果;
ObjectAnimator --继承于ValueAnimator,可以很好滴使用属性对话框架;
AnimatorUpdateListener -- 用于动画监听器
AnimatorListenerAdapter-- 用于动画监听器
PropertyValuesHolder --用于控制动画集合的显示效果
Animatorset --用于控制动画集合的显示效果
TypeEvaluators ---值计算器,用于控制值变化的规律
ObjectAnimator --继承于ValueAnimator,可以很好滴使用属性对话框架;
AnimatorUpdateListener -- 用于动画监听器
AnimatorListenerAdapter-- 用于动画监听器
PropertyValuesHolder --用于控制动画集合的显示效果
Animatorset --用于控制动画集合的显示效果
TypeEvaluators ---值计算器,用于控制值变化的规律
Interprolators ---插值计算器,用于控制值变化的规律
MainActivity
package test.ban.com.test; import android.animation.ValueAnimator; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); } public void onClick(View view) { final Button button = (Button) view; ValueAnimator animator = ValueAnimator.ofInt(0, 100); animator.setDuration(10000);//10s内实现计数完成✅ animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {//实现变化的监听 @Override public void onAnimationUpdate(ValueAnimator animation) { Integer animatedValue = (Integer) animation.getAnimatedValue();//获取数值强转为Integer button.setText("" + animatedValue);//Integer转换为String 并显示在button上。 } }); animator.start(); } }activity_my.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/bt" android:text="123" android:layout_centerInParent="true" android:onClick="onClick" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </RelativeLayout>