标签:
1、ValueAnimator
(1)继承关系图
继承自父类Animator
(2)创建对象,一般来说,常用来创建ValueAnimator的对象为静态方法ofInt,ofFloat,ofPropertyValuesHolder,ofObject,在内部实际上也是调用相关的属性构造对象
public static ValueAnimator ofInt(int... values) { ValueAnimator anim = new ValueAnimator(); anim.setIntValues(values); return anim; }
(3)启动动画:start
(4)监听值变化事件:addUpdateListener
(5)实例:点击按钮开始动画,改变TextView的文字
btnStart.setOnClickListener(new OnClickListener() { @SuppressLint("NewApi") @Override public void onClick(View v) { ValueAnimator animator = ValueAnimator.ofFloat(0, 1f, 3f, 100f,1000f); animator.setDuration(300).addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { tvText.setText(animation.getAnimatedValue()+""); } }); animator.start(); } });
标签:
原文地址:http://www.cnblogs.com/hpustudent/p/4589813.html