0

タッチすると、りんごが木から「落ち」(平行移動)、自身の周りを回転して平行移動するはずです。

            Animation apple3_anim = AnimationUtils.loadAnimation(this,
            R.anim.apple3_animation);
            apple3.startAnimation(apple3_anim);

            RotateAnimation r = new RotateAnimation(0.0f,
            720.0f, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            r.setDuration(2000);
            apple3.startAnimation(r);

apple3_animation.xml ファイルの xml コード:

<?xml version="1.0" encoding="utf-8"?>

<translate
    android:fromXDelta="0"
    android:toXDelta="0"

    android:fromYDelta="0"
    android:toYDelta="450"
    android:duration="1200"
    >

</translate>

問題は、アニメーションが順番に発生せず、最後の 'r' アニメーションのみが実行されることです。リンゴは自身の周りを 720 度回転します。順番に実行するにはどうすればよいですか?すべてのものを xml ファイルに入れても、 xml で、最後のアニメーションだけが実行されます!

4

1 に答える 1

0

アニメーターを使用すると、すばやく解決できます

apple3.animate().translationY(450).setDuration(1200).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            iv.animate().rotation(720).setDuration(2000);
        }
    }).start(); 
于 2015-07-03T05:24:53.663 に答える