ValueAnimator animator = ValueAnimator.ofInt(mStartValue, mEndValue);
animator.setDuration(duration);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
t_text.setText(animation.getAnimatedValue().toString());
}
});
animator.start();
mStartValue:初始值
mEndValue:结束值
duration:动画时长
t_text,控件
给图片设置动画
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(image_qq, "alpha", 0, 0, 0.8f);
objectAnimator.setDuration(2000);
objectAnimator.setInterpolator(new LinearInterpolator());
objectAnimator.start();
ObjectAnimator animator = ObjectAnimator.ofFloat(image_qq, "rotation", 0f, 180f);
animator.setDuration(2000);
animator.start();