Android: FillAfter not working for ScaleAnimation in ImageView
<p>I am applying three animations in an ImageView, one after another. I have a AnimationListener for each animation, so inside the onAnimationEnd, I start the next one, so they dont overlap. The animations are this: scale in, fade out and the last one fade in. The fade in animation will restart the scale in animation again, to these animations will be running "forever". What I am trying to achieve is the same effect Twitter has applied to their new home screen, where they keep changing the pictures.</p>

<p>The problem with my animations is that after scaling in the ImageView and before staring the the fade out animation, the ImageView gets reseted and the scale change is lost, even setting fillAfter in the code or in the xml file. Here is the code for handling the animation events:</p>

<pre><code>    mAnimationFadeIn = AnimationUtils.loadAnimation(this, R.anim.fade_in);
    mAnimationFadeIn.setFillAfter(true);
    mAnimationFadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out);
    mAnimationFadeOut.setFillAfter(true);
    mAnimationScaleIn = AnimationUtils.loadAnimation(this, R.anim.slow_scale_in);
    mAnimationScaleIn.setFillAfter(true);
    mAnimationScaleIn.setFillEnabled(true);
    mAnimationScaleIn.setFillBefore(false);
    mAnimationScaleIn.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {}

        @Override
        public void onAnimationRepeat(Animation animation) {}

        @Override
        public void onAnimationEnd(Animation animation) {
            mImageView.startAnimation(mAnimationFadeOut);
        }
    });

    mAnimationFadeOut.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {}

        @Override
        public void onAnimationRepeat(Animation animation) {}

        @Override
        public void onAnimationEnd(Animation animation) {
            mImageView.setImageResource(mImages[++mImageIndex &gt; 2 ? mImageIndex=0 : mImageIndex]);
            mImageView.startAnimation(mAnimationFadeIn);
        }
    });

    mAnimationFadeIn.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {}

        @Override
        public void onAnimationRepeat(Animation animation) {}

        @Override
        public void onAnimationEnd(Animation animation) {
            mImageView.startAnimation(mAnimationScaleIn);
        }
    });

    mImageView.startAnimation(mAnimationScaleIn);
</code></pre>

<p>and here are my animations:</p>

<p>scale in:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:duration="9000"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:interpolator="@android:anim/linear_interpolator"
    android:pivotX="50.0%"
    android:pivotY="50.0%"
    android:toXScale="1.1"
    android:toYScale="1.1" /&gt;
</code></pre>

<p>fade in:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromAlpha="0.0"
    android:interpolator="@android:anim/linear_interpolator"
    android:toAlpha="1.0" /&gt;
</code></pre>

<p>fade out:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromAlpha="1.0"
    android:interpolator="@android:anim/linear_interpolator"
    android:toAlpha="0.0" /&gt;
</code></pre>

<p>Is there a way to keep the scale transformation before starting the fade out animation?
I have tried all the combinations for setFillAfter, setFillBefore and setFillEnabled and no way I can get the scale transformation to be kept after the scale animation is over.</p>

<p>Many thanks
T</p>
