title: Android 2.3: Grow/Shrink animation bug?
body: <p>For my application, I'm trying to add a [grow/shrink + alpha change] animation to each ImageView in my layout.  I managed to get the animations working and have each of the animations persist after they're done by setting <b>fillAfter="true"</b> for both of my XML files (grow.xml and shrink.xml).  However, there seems to be some weird animation bug that causes unselected images to grow and then 'snap' back to normal size when I set <b>fillAfter="true</b> for shrink.xml!  Let me explain how the application works and then give a scenario so it becomes more clear:</p>
  
  <p>Initially, all the images have their alpha levels set to 50%.  When I click on a particular image, it will grow to 120% and its alpha level will become 100% ('light up' effect).  When I click on another image, the previously selected image will shrink back to 100% and its alpha level will return to 50% and the currently selected image will grow as described previously.  </p>
  
  <p>In my layout, I have three, equal sized images placed in a row.  I click the first image, then click the second one then click the first one again.  Ok, no problems there.  Now, I click on the third image and I get the weird snapping problem for the first image.  Any idea how to fix this?</p>
  
  <p>I've tried:</p>
  
  <ol>
  <li><b>image.setAlpha(...)</b> to avoid having to set the alpha level in shrink.xml then calling <b>fillAfter="true"</b>, but unfortunately that's an API 11 call</li>
  <li>setting the <b>fillAfter</b> attribute of only my alpha tags to <b>true</b> in shrink.xml </li>
  <li>calling <b>image.startAnimation(fadeOut)</b> right after a shrink animation but that looks horrible. </li>
  <li>Overriding <strong>onAnimationEnd()</strong>, but this call never gets reached(??)</li>
  </ol>
  
  <p>shrink.xml:
  <p><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;set xmlns:android="http://schemas.android.com/apk/res/android"
  android:interpolator="@android:anim/accelerate_decelerate_interpolator"
  android:fillAfter="true"&gt;
      &lt;scale 
      android:fromXScale="1.2"
      android:toXScale="1.0"
      android:fromYScale="1.2"
      android:toYScale="1.0"
      android:duration="300"
      android:pivotX="50%"
      android:pivotY="50%"/&gt;
      &lt;alpha
      android:fromAlpha="1.0"
      android:toAlpha="0.5"
      android:duration="300"/&gt;
  &lt;/set&gt;</code></p>
  
  <p>grow.xml
  <p><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;set
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:interpolator="@android:anim/accelerate_decelerate_interpolator"
  android:fillAfter="true"&gt;
      &lt;scale 
      xmlns:android="http://schemas.android.com/apk/res/android"
       android:fromXScale="1.0"
       android:toXScale="1.20"
       android:fromYScale="1.0"
       android:toYScale="1.20"
       android:duration="300"
       android:pivotX="50%"
       android:pivotY="50%"
       /&gt;
       &lt;alpha
      android:fromAlpha="0.5"
      android:toAlpha="1.0"
      android:duration="300"/&gt;
  &lt;/set&gt;</code></p>
  
  <p>fade_out.xml:
  <p><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;alpha
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:startOffset="300"
  android:fromAlpha="1.0"
  android:toAlpha="0.5"
  android:fillAfter="true"&gt;
  &lt;/alpha&gt;</code></p>
  
  <p>main.xml:
  <p><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:gravity="center"&gt;
      &lt;ImageView
      android:id="@+id/image1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="20dip"
      android:paddingRight="20dip"
      android:src="@drawable/image1"/&gt;
      &lt;ImageView
      android:id="@+id/image2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="20dip"
      android:paddingRight="20dip"
      android:src="@drawable/image2"/&gt;
      &lt;ImageView
      android:id="@+id/image3"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="20dip"
      android:paddingRight="20dip"
      android:src="@drawable/image3"/&gt;
  &lt;/LinearLayout&gt;</code></p>
  
  <p>Test.java:</p>
  
  <pre><code>    public class Test extends Activity {
      private View mSelected;
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      final Animation fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out);
      final Animation grow = AnimationUtils.loadAnimation(this, R.anim.grow);
      final Animation shrink = AnimationUtils.loadAnimation(this, R.anim.shrink);
  
      OnClickListener listener = new OnClickListener() {
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              if (mSelected == v) 
                  return;
  
              if (mSelected != null) 
                  mSelected.startAnimation(shrink);
  
              mSelected = v;
              mSelected.startAnimation(grow);             
          }
      };
  
      ImageView image1 = (ImageView)findViewById(R.id.image1);
      image1.startAnimation(fadeOut);
      image1.setOnClickListener(listener); 
  
      ImageView image2 = (ImageView)findViewById(R.id.image2);
      image2.startAnimation(fadeOut);
      image2.setOnClickListener(listener);
  
      ImageView image3 = (ImageView)findViewById(R.id.image3);
      image3.startAnimation(fadeOut);
      image3.setOnClickListener(listener);
  }}
  </code></pre>