title: Animatedly reduce button size on press and regain it's size on release
body: <p>I want a to create a button that changes size (little bit smaller) when it's pressed, and after the button is released again the size should change back to normal size.I am using Scale xml to achieve this but it re-positioned itself even if i do not release button.</p>
  
  <p><strong>button here i am referring to imageview.</strong></p>
  
  <p>here is my source code :-</p>
  
  <pre><code>imgSpin = (ImageView) findViewById(R.id.iv_spins);
      imgSpin.setOnTouchListener(new View.OnTouchListener() {
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                  switch (event.getAction()) {
                  case MotionEvent.ACTION_DOWN:
                      imgSpin.startAnimation(mAnimation);
                      spinslot();
                      break;
  
                  case MotionEvent.ACTION_UP:
                      imgSpin.clearAnimation();
                      imgSpin.setEnabled(false);
                      break;
                  }
                  return true;
              }
          });
  </code></pre>
  
  <p>my scale Xml :-</p>
  
  <pre><code>&lt;scale xmlns:android="http://schemas.android.com/apk/res/android"
      android:duration="200"
      android:fromXScale=".8"
      android:fromYScale=".8"
      android:pivotX="50%"
      android:pivotY="50%"
      android:toXScale="1.0"
      android:toYScale="1.0" &gt;
  
  &lt;/scale&gt;
  </code></pre>
  
  <p>my XML:-</p>
  
  <pre><code> &lt;LinearLayout
                  android:id="@+id/layout_status"
                  android:layout_width="match_parent"
                  android:layout_height="0dp"
                  android:layout_weight=".2"
                  android:orientation="horizontal" &gt;
  
                  &lt;View
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight=".5" /&gt;
  
                  &lt;ImageView
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="2.1"
                      android:background="@drawable/bootser" /&gt;
  
                  &lt;LinearLayout
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="2.5"
                      android:background="@drawable/bet_bg"
                      android:gravity="center_vertical"
                      android:orientation="horizontal"
                      android:weightSum="1" &gt;
  
                      &lt;ImageView
                          android:layout_width="0dp"
                          android:layout_height="match_parent"
                          android:layout_gravity="center_vertical"
                          android:layout_weight=".2"
                          android:src="@drawable/leftarrow" /&gt;
  
                      &lt;TextView
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="1dp"
                          android:layout_weight=".6"
                          android:gravity="center"
                          android:text="Bet"
                          android:textColor="@android:color/white" /&gt;
  
                      &lt;ImageView
                          android:layout_width="0dp"
                          android:layout_height="40dp"
                          android:layout_gravity="center_vertical"
                          android:layout_weight=".2"
                          android:src="@drawable/rightarrow" /&gt;
                  &lt;/LinearLayout&gt;
  
                  &lt;LinearLayout
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="2.5"
                      android:background="@drawable/container"
                      android:gravity="center" &gt;
  
                      &lt;TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="2dp"
                          android:text="winning"
                          android:textColor="@android:color/white" /&gt;
                  &lt;/LinearLayout&gt;
  
                  &lt;ImageView
                      android:id="@+id/iv_spins"
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="1.9"
                      android:background="@drawable/spin" /&gt;
  
                  &lt;View
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight=".5" /&gt;
              &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I tried with paramLayout but as i set the weights in XML so it do not give me the effect on animation.</p>
  
  <p>i already use this approach :-</p>
  
  <pre><code>case MotionEvent.ACTION_DOWN:
                  ViewGroup.LayoutParams params = imgSpin.getLayoutParams();
                  // Button new width
                  params.width = params.width - (params.width *90/100);
  
                  imgSpin.setLayoutParams(params);
  
                  break;
  </code></pre>
  
  <p><strong>params.width always return me zero</strong> so i tried to do this with weight , by using weight my view glitch on click ..i want it to be smooth so i am preferring scaling  </p>
  
  <p>Second approach :- </p>
  
  <pre><code>case MotionEvent.ACTION_DOWN:
                  LinearLayout.LayoutParams params = (android.widget.LinearLayout.LayoutParams) imgSpin
                          .getLayoutParams();
                  // Button new width
                  params.weight = 1.7f;
  
                  imgSpin.setLayoutParams(params);
                  // imgSpin.startAnimation(mAnimation);
                  // spinslot();
                  break;
  
              case MotionEvent.ACTION_UP:
                  LinearLayout.LayoutParams params2 = (android.widget.LinearLayout.LayoutParams) imgSpin
                          .getLayoutParams();
                  // Button new width
                  params2.weight = 1.9f;
  
                  imgSpin.setLayoutParams(params2);
                  // imgSpin.clearAnimation();
                  imgSpin.setEnabled(false);
                  break;
              }
              return true;
  </code></pre>
  
  <p><strong>it works but not smooth</strong></p>
  
  <p>Please tell me how to do</p>
  
  <p>Thanks</p>