title: Android Layout Animations from bottom to top and top to bottom on ImageView click
body: <p>I have created a view in Android and I need to animate it from bottom to top and vice-versa. when I clicked on <code>ImageView</code> I need to animate the complete <code>RelativeLayout</code> from bottom to top and it is succeeded. But when I click again on <code>ImageView</code> and it is not moving down. Also, when I click on its original place, when I click the original position of the <code>ImageView</code> animation runs but the <code>RelativeLayout</code> moves down from the original position not a top to bottom.</p>
  
  <p>This is my code:</p>
  
  <pre><code>ImageView iv_header;
  
  RelativeLayout rl_footer;
  
  boolean isBottom = true;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.rateus_layout);
      rl_footer = (RelativeLayout) findViewById(R.id.rl_footer);
      iv_header = (ImageView) findViewById(R.id.iv_up_arrow);
  
      iv_header.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              if (isBottom) {
                  FooterAnimation();
                  isBottom = false;
              } else {
                  headerAnimation();
                  isBottom = true;
              }
  
          }
      });
  }
  
  public void FooterAnimation() {
      Animation hide = AnimationUtils.loadAnimation(this, R.anim.move);
      rl_footer.startAnimation(hide);
  }
  
  public void headerAnimation() {
      Animation hide = AnimationUtils.loadAnimation(this, R.anim.footer);
      rl_footer.startAnimation(hide);
  }
  </code></pre>
  
  <p>The animation file from bottom to top(Complete Relative Layout is moved from bottom to Top):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;translate xmlns:android="http://schemas.android.com/apk/res/android"
  android:duration="1500"
  android:fillAfter="true"
  android:fromYDelta="0%p"
  android:toYDelta="-85%p" /&gt;
  </code></pre>
  
  <p>The animation file from Top to bottom(i want again Relative Layout is moved from Top to Bottom):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;translate xmlns:android="http://schemas.android.com/apk/res/android"
  android:duration="1500"
  android:fillAfter="true"
  android:fromYDelta="0%p"
  android:toYDelta="84%p" /&gt;
  </code></pre>
  
  <p>The Xml File:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/rl_main"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@drawable/autograph_bg" &gt;
  
  &lt;RelativeLayout
      android:id="@+id/rl_footer"
      android:layout_width="fill_parent"
      android:layout_height="70dp"
      android:layout_alignParentBottom="true"
      android:background="@drawable/down_manu_bar1" &gt;
  
      &lt;ImageView
          android:id="@+id/iv_new_file"
          android:layout_width="25dp"
          android:layout_height="25dp"
          android:layout_alignParentLeft="true"
          android:layout_centerVertical="true"
          android:layout_marginLeft="18dp"
          android:onClick="onNewFileClick"
          android:src="@drawable/file_icon" /&gt;
  
      &lt;TextView
          android:id="@+id/tv_new_file"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/iv_new_file"
          android:layout_below="@+id/iv_new_file"
          android:text="New"
          android:textColor="#ffffff" /&gt;
  
      &lt;ImageView
          android:id="@+id/iv_insert"
          android:layout_width="25dp"
          android:layout_height="25dp"
          android:layout_alignTop="@+id/iv_new_file"
          android:layout_marginLeft="30dp"
          android:layout_toRightOf="@+id/iv_new_file"
          android:src="@drawable/insert_icon" /&gt;
  
      &lt;TextView
          android:id="@+id/tv_insert"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/iv_insert"
          android:layout_below="@+id/iv_insert"
          android:text="Insert"
          android:textColor="#ffffff" /&gt;
  
      &lt;ImageView
          android:id="@+id/iv_up_arrow"
          android:layout_width="45dp"
          android:layout_height="45dp"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"
          android:paddingBottom="10dp"
          android:src="@drawable/up_arrow" /&gt;
  
      &lt;ImageView
          android:id="@+id/iv_down_arrow"
          android:layout_width="45dp"
          android:layout_height="45dp"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"
          android:background="@drawable/down_arrow"
          android:paddingBottom="10dp"
          android:visibility="gone" /&gt;
  
      &lt;ImageView
          android:id="@+id/iv_save"
          android:layout_width="25dp"
          android:layout_height="25dp"
          android:layout_alignTop="@+id/iv_insert"
          android:layout_marginLeft="30dp"
          android:layout_toRightOf="@+id/iv_up_arrow"
          android:src="@drawable/save" /&gt;
  
      &lt;TextView
          android:id="@+id/tv_save"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/iv_save"
          android:layout_alignParentBottom="true"
          android:text="Save"
          android:textColor="#ffffff" /&gt;
  
      &lt;ImageView
          android:id="@+id/iv_settings"
          android:layout_width="25dp"
          android:layout_height="25dp"
          android:layout_alignTop="@+id/iv_save"
          android:layout_marginLeft="27dp"
          android:layout_toRightOf="@+id/tv_save"
          android:paddingTop="2dp"
          android:src="@drawable/icon_settings" /&gt;
  
      &lt;TextView
          android:id="@+id/tv_settings"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_marginLeft="260dp"
          android:text="Settings"
          android:textColor="#ffffff" /&gt;
    &lt;/RelativeLayout&gt;
   &lt;/RelativeLayout&gt;
  </code></pre>