title: Android: Animation gets clipped by parent view
body: <p>I currently have an ImageView which i am applying a scale animation to. This view is inside a relative layout which has layout_height and layout_width set as wrap_content. The problem is when the animation starts it makes the imageview bigger than its parent layout and the image then gets cut off. Is there anyway around this?</p>
  
  <p>Here is a working sample:</p>
  
  <p>xml file - </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"&gt;
  &lt;RelativeLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="20dip" 
      android:layout_gravity="center_horizontal"&gt;
      &lt;ImageView
          android:id="@+id/imgO"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/circle"/&gt;
      &lt;/RelativeLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>java file - </p>
  
  <pre><code>ImageView imgO;
  
  ScaleAnimation makeSmaller;
  ScaleAnimation makeBigger;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.titlescreen);
  
      //Animation
      imgO = (ImageView)findViewById(R.id.imgO);
  
      makeSmaller = new ScaleAnimation((float)10.0, (float)1.0, (float)10.0, (float)1.0, Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5);
      makeSmaller.setAnimationListener(new MyAnimationListener());
      makeSmaller.setFillAfter(true);
      makeSmaller.setDuration(500);
      makeBigger = new ScaleAnimation((float)1.0, (float)10.0, (float)1.0, (float)10.0, Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5);
      makeBigger.setAnimationListener(new MyAnimationListener());
      makeBigger.setFillAfter(true);
      makeBigger.setDuration(750);
      imgO.startAnimation(makeBigger);
  }
  
  class MyAnimationListener implements AnimationListener {
  
      public void onAnimationEnd(Animation animation) {
  
          ScaleAnimation sa = (ScaleAnimation)animation;
  
          if (sa.equals(makeSmaller))
              imgO.startAnimation(makeBigger);
          else
              imgO.startAnimation(makeSmaller);
      }
  
      public void onAnimationRepeat(Animation animation) {
      }
  
      public void onAnimationStart(Animation animation) {
      }
  
  }
  </code></pre>
  
  <p>Thanks.</p>