0

On touch apple "falls" (translates) down from a tree and should rotate around itself and translate.

            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);

the xml code for apple3_animation.xml file:

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

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

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

</translate>

The issue is that the animations don't happen sequentially,only the last 'r' animation gets executed - the apple rotates around itself 720degrees. How do I make it go sequentially? even if i put all things in xml file, in the xml , only the last animation gets executed!

ERJAN
  • 23,696
  • 23
  • 72
  • 146
  • Add these two animation into [AnimationSet](http://developer.android.com/reference/android/view/animation/AnimationSet.html) – calvinfly Jul 03 '15 at 04:58

1 Answers1

0

using animator can solve it quikely

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(); 
rainash
  • 864
  • 6
  • 15