title: Android Programming rectangle animation (height) & by click stop animation
body: <p>I want to create a rectangle in the middle of the screen (bottom). When I start the app the rectangle should grow (max height = screen height). And if I tap on the screen (random position) the animation should stop and the height should stay. How can I do something like this? Can anyone give me some keywords or links?</p>
  
  <p>Now I started with the rectangle an the animation. My first question should I place the rectangle into a <code>ImageView</code>? I want to get the position from the rectangle when I tapped the screen.</p>
  
  <p>Here is the <code>activity_main.xml</code></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="nocompany.gamefirsttry.main_activity"&gt;
  
      &lt;LinearLayout
          android:id="@+id/linearLayout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"/&gt;
  
  
      &lt;ImageView
          android:id="@+id/rectangle"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/rectangle"/&gt;
  &lt;/RelativeLayout&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><code>@drawable/rectangle.xml</code></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:dither="true"
      android:shape="rectangle"&gt;
  
      &lt;gradient
          android:startColor="#000"
          android:endColor="#000"/&gt;
  
      &lt;size
          android:height="100px"
          android:width="50px"/&gt;
  &lt;/shape&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><code>@anim/rectangle_anim.xml</code></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;set xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;scale
          android:duration="5000"
          android:fillAfter="true"
          android:fromXScale="1.0"
          android:fromYScale="1.0"
          android:pivotX="0%"
          android:pivotY="0%"
          android:toXScale="1.0"
          android:toYScale="15.0" &gt;
      &lt;/scale&gt;
  &lt;/set&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><code>main_activity.java</code></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>package nocompany.gamefirsttry;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.animation.Animation;
  import android.view.animation.AnimationUtils;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  
  public class main_activity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          ImageView rectangle = (ImageView)findViewById(R.id.rectangle);
          Animation recSize = AnimationUtils.loadAnimation(this, R.anim.rectangle_anim);
          rectangle.startAnimation(recSize);
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I hope you understood my question and give me some tips/hints or links.</p>