动画

改变背景颜色渐变,backgroundColor可改成其他属性,例如TextView的setTextColor,让文字闪烁渐变,则写成textColor即可
ValueAnimator coloAnimation = ObjectAnimator.ofInt(imageView, "backgroundColor", 0xFFFF0808, 0xFF8080FF);
coloAnimation.setDuration(3000);
coloAnimation.setEvaluator(new ArgbEvaluator());
coloAnimation.setRepeatCount(ValueAnimator.INFINITE);
coloAnimation.setRepeatMode(ValueAnimator.REVERSE);
coloAnimation.start();

组合动画的使用

AnimatorSet set=new AnimatorSet();
set.playTogether(
        ObjectAnimator.ofFloat(imageView, "scaleX", 1,0.1f),
        ObjectAnimator.ofFloat(imageView, "scaleY", 1,0.1f),
        ObjectAnimator.ofFloat(imageView, "translationX", 0,button1.getLeft()-imageView.getLeft()),
        ObjectAnimator.ofFloat(imageView, "translationY", 0,button1.getTop()-imageView.getTop()),
        ObjectAnimator.ofFloat(imageView, "alpha", 1,0.1f)
);
set.setDuration(3000).start();

猜你喜欢

转载自my.oschina.net/u/1268043/blog/1636038