我想在视图上运行多个AnimatorSet。 AnimatorSet应该一个接一个地连续运行。我想这样做而不使用处理程序延迟时间。我该怎么做?
答案 0 :(得分:2)
在您的代码中尝试此操作。
AnimatorSet bouncer = new AnimatorSet();
ObjectAnimator anim = ObjectAnimator.ofFloat(mTextView, "rotationX", 0f, 180f);
anim.setDuration(2000);
ObjectAnimator anim2 = ObjectAnimator.ofFloat(mTextView, "rotationX", 180f, 0f);
anim2.setDuration(2000);
ObjectAnimator anim3 = ObjectAnimator.ofFloat(mTextView, "rotationY", 0f, 180f);
anim3.setDuration(2000);
ObjectAnimator anim4 = ObjectAnimator.ofFloat(mTextView, "rotationY", 180f, 0f);
anim4.setDuration(2000);
bouncer.playSequentially(anim, anim2, anim3, anim4);
bouncer.start();
注意强>
方法:
play(Animator anim);
play (Animator anim): // add an animation and return AnimatorSet.Builder
playSequentially(列出项目);
playSequentially (List items): // add a set of animations, play sequentially, and play them one by one
playSequentially(Animator ... Items);
playSequentially (Animator... Items): // add a set of animations, play sequentially, and play them one by one
playTogether(收藏品);
playTogether (Collection items): // add a set of animations, played sequentially, and played together
playTogether(Animator ... Items);
playTogether (Animator... Items): // add a set of animations, play sequentially, and play together