Apply one animation to multiple views at the same time

前端 未结 3 418
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-29 23:40

So Id like to rotate a handful of views all at the same time, all using the same rotation specs. The issue is that for some reason the rotation acts differently for the sec

3条回答
  •  -上瘾入骨i
    2020-12-30 00:39

    Do it like this:

    ObjectAnimator anim = ObjectAnimator.ofFloat(view, "y", 100f);
    arrayListObjectAnimators.add(anim);
    
    ObjectAnimator anim1 = ObjectAnimator.ofFloat(view, "x", 0f);
    arrayListObjectAnimators.add(anim1);
    
    ObjectAnimator[] objectAnimators = arrayListObjectAnimators.toArray(new ObjectAnimator[arrayListObjectAnimators.size()]);
    AnimatorSet animSetXY = new AnimatorSet();
    animSetXY.playTogether(objectAnimators);
    animSetXY.duration(1000);
    animSetXY.start();
    

提交回复
热议问题