动画[5]PropertyAnimator AnimatorSet

【参考链接】

 

还可以使用AnimatorSet将多个ValueAnimator/ObjectAnimator组合到一起

可以通过如下方式来控制多个动画的协作方式

.play(anim1).with(anim2)//同时执行

                     .before(anim2)//先执行anim1,再执行anim2

                     .after(anim2)//先执行anim2,再执行anim1

.playTogether(anim1,anim2)

.playSequentially(anim1,anim2)

 

并且,参见《View[7] Property》,由于ViewProperty之间是相互独立的,因此跟TweenAnimationAnimationSet不同,AnimatorSet可以实现一边移动一边旋转的效果。

 

ValueAnimatoranimator1 = ValueAnimator.ofArgb(/*RED*/0xFFFF8080, /*BLUE*/0xFF8080FF);
animator1.addUpdateListener(
       
new ValueAnimator.AnimatorUpdateListener() {
           
@Override
           
public void onAnimationUpdate(ValueAnimator animator) {

               
int animatedValue = (int) animator.getAnimatedValue();
               
tv.setBackgroundColor(animatedValue);

           
}
       })
;

ObjectAnimatoranimator2 = ObjectAnimator.ofFloat(tv, "translationY", 100, 300);

ObjectAnimatoranimator3= ObjectAnimator.ofFloat(tv, "rotation", 0, 360);

ObjectAnimator animator4=ObjectAnimator.ofFloat(tv, "scaleX", 1, 0.5f);

AnimatorSet set=new AnimatorSet();
set.playTogether(animator1, animator2, animator3, animator4);
set.setDuration(3000);
set.start();

 


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值