2017-09-05 5 views
2

ビューで複数のAnimatorSetを実行したい。 AnimatorSetは連続して1つずつ実行する必要があります。私は時間遅延のハンドラを使わずにやりたいどうしたらいいですか?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(リストアイテム);

    playSequentially (List items): // add a set of animations, play sequentially, and play them one by one 
    
  3. playSequentially(アニメーター...アイテム)。

    playSequentially (Animator... Items): // add a set of animations, play sequentially, and play them one by one 
    
  4. playTogether(コレクションアイテム);

    playTogether (Collection items): // add a set of animations, played sequentially, and played together 
    
  5. playTogether(アニメーター...アイテム)。

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

これは私の場合は例外です。 –

+0

'mTextView'をあなたの' View'に変更します。 – KeLiuyue

+0

上記のコメントをお読みください。ありがとうbtw。 :) –

関連する問題