2017-02-27 9 views
1

表示を外していますが、カードを回転させるような表示になります。
以下はビューを回転させますが、私がしようとしているものではありません。回転アニメーションの回転アニメーションがビューから外になっています

<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <rotate 
     android:duration="1500" 
     android:fromDegrees="0" 
     android:pivotX="100%" 
     android:pivotY="50%" 
     android:startOffset="0" 
     android:toDegrees="220" /> 
</set> 

私は何をした後だと、固定中心の周り自体の回転が、カードを投げると似た動きではありません。
どうすればいいですか?

更新
私は@loadedionからの回答後にこれを試みたが、動作していない:

ObjectAnimator rotateAnimation = ObjectAnimator.ofFloat(rootView, "rotation", 0.0f, 360f); 
rotateAnimation.setDuration(5000); 

ObjectAnimator throwAnimation = ObjectAnimator.ofFloat(rootView, "x", rootView.getX(), rootView.getX() + 200); 
throwAnimation.setInterpolator(new AccelerateInterpolator()); 
     throwAnimation.setDuration(3000); 
ObjectAnimator throwAnimation2 = ObjectAnimator.ofFloat(rootView, "y", rootView.getY(), rootView.getY() + 200);  
throwAnimation.setInterpolator(new AccelerateInterpolator()); 
throwAnimation.setDuration(3000); 
AnimatorSet cardThrowAnimations = new AnimatorSet(); 
cardThrowAnimations.playSequentially(rotateAnimation, throwAnimation, throwAnimation2); 
     cardThrowAnimations.start(); 
+0

私はplaySequentially'が各アニメーションまで待機します '信じます次のカードが始まる前に完了しているので、カードが5秒間本当にゆっくりと回転し、次に3秒間右に移動してから3秒間少し下に移動するように見えますconds。それはあなたが見ているものですか? 'playTogether'を使うと同時にすべてのアニメーションを実行します。 – loadedion

答えて

0

あなたがスピンするビューをしたい場合は、あなたがそれにアニメーションを適用する必要があります。

ObjectAnimator rotateAnimation = ObjectAnimator.ofFloat(targetView, "rotation", 0.0f, 360f); 
rotateAnimation.setRepeatCount(ObjectAnimator.INFINITE); 
rotateAnimation.setRepeatMode(ObjectAnimator.RESTART); 
rotateAnimation.setInterpolator(new LinearInterpolator()); 
rotateAnimation.setDuration(DURATION_ROTATION); 

そして、あなたはそれが回転している間、それがスローカードのように引き出したい場合、あなたはそれがx位置だ設定する別のObjectAnimatorを作成することができます。

ObjectAnimator throwAnimation = ObjectAnimator.ofFloat(targetView, "x", targetView.getX(), targetView.getX() + 500); // move 500 pixels to the right 
throwAnimation.setInterpolator(new AccelerateInterpolator()); 
throwAnimation.setDuration(DURATION_THROW); 

そして

rotateAnimation.start(); 
throwAnimation.start(); 

代わりにアニメーションを開始し、あなたも一緒にそれらを開始するAnimatorSetでそれらを組み合わせることができます:

AnimatorSet cardThrowAnimations = new AnimatorSet(); 
cardThrowAnimations.playTogether(rotateAnimation, throwAnimation); 
cardThrowAnimations.start(); 
+0

私はおそらく2つのアニメーションを使う必要があると思っていましたが、2番目のアニメーションのX、Yの位置を調べるにはどうしたらいいですか? – Jim

+0

START_X_POSITIONとSTART_Y_POSITIONは、最初のローテーションが終了した後のビューの新しい位置によって決定される必要があります。どうやって? – Jim

+0

@Jimレイアウトのカードビューをアニメーションの開始位置に配置すると、 'targetPosition.getX()'と 'targetPosition.getY()'で開始x、yを得ることができます(必ずpollビューの作成後のx、yの位置) – loadedion

関連する問題