【参考链接】

 

还可以使用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();

 

动画[5]PropertyAnimator AnimatorSet

 

相关文章:

  • 2022-02-07
  • 2022-02-21
  • 2022-12-23
  • 2021-04-18
  • 2021-09-15
  • 2022-03-06
  • 2021-12-23
猜你喜欢
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-07-11
相关资源
相似解决方案