2017-09-05 26 views
2

我想在视图上运行多个AnimatorSet。 AnimatorSet应该连续运行。我想在不使用时间延迟处理程序的情况下执行此操作。我该怎么做?如何连续启动AnimatorSet?

+0

我试图用,但有那个漫画家集对象得到释放异常。 –

+0

我有单独的类来创建和运行动画集。无论何时我需要创建或运行动画设置,我都会使用它的实例。如果我连续调用运行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(); 

方法:

  1. 播放(动画阿尼姆);

    play (Animator anim): // add an animation and return AnimatorSet.Builder 
    
  2. playSequentially(List items);

    playSequentially (List items): // add a set of animations, play sequentially, and play them one by one 
    
  3. playSequentially(Animator ... Items);

    playSequentially (Animator... Items): // add a set of animations, play sequentially, and play them one by one 
    
  4. playTogether(Collection items);

    playTogether (Collection items): // add a set of animations, played sequentially, and played together 
    
  5. playTogether(Animator ... Items);

    playTogether (Animator... Items): // add a set of animations, play sequentially, and play together 
    
+0

这给我例外。 –

+0

将'mTextView'更改为'View'。 – KeLiuyue

+0

请阅读以上评论。谢谢btw。 :) –