Search code examples
androidanimationtween

Android : Tween animation: Moving an ImageView


I have a problem with tween animation in android , I try to move an ImageView item from center of screen to top of screen but after end of transform ImageView returns to first position! I use this code:

   <?xml version="1.0" encoding="utf-8"?>
       <translate 
        xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@android:anim/bounce_interpolator"
         android:fromYDelta="0%"
         android:toYDelta="-1500%"
         android:duration="3000"
         android:startOffset="3000">
         </translate>

private void RunAnimations() {

    Animation animation = AnimationUtils.loadAnimation(this, R.anim.move_up_maxname);
    animation.reset();
    ImageView maxName = (ImageView) findViewById(R.id.imageView1);
    maxName.clearAnimation();
    maxName.startAnimation(animation);
}

Can anyone help me?
Thanks


Solution

  • You need to take a look at setFillAfter:

    If fillAfter is true, the transformation that this animation performed will persist when it is finished.