title: Stop animation on button click
body: <p>I am setting a animation on the imageview</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          i=(ImageView)findViewById(R.id.imageView1);
          d=(Button)findViewById(R.id.button1);
          a=new AnimationSet(false);
          ScaleAnimation s=new ScaleAnimation(0, 2, 0, 2);
          TranslateAnimation t=new TranslateAnimation(0, 100, 0, 0);
  
          a.addAnimation(s);
          a.addAnimation(t);
          a.setRepeatCount(0); 
          a.setDuration(500);     
          a.setFillAfter(false);
  
          a.setInterpolator(new AccelerateDecelerateInterpolator()); i.clearAnimation();
  
          d.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  i.clearAnimation();
  
              }
          });
  
          i.setOnTouchListener(new OnTouchListener() {
  
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                  // TODO Auto-generated method stub
  
                  i.startAnimation(a);
                  System.out.println("OnTouch called&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;");
                  return false;
              }
          });
      }
  }
  </code></pre>
  
  <p>now the problem is to stop the animation and restore the previous state on the button click till that time the image should stay as it is set to be in animation.
  I</p>