title: Stopping animations in Android Studio
body: <p>I am trying to make an animation in android studio that will start when I double click the screen. Since I am using a scroll view and that takes up the whole screen I used that as the view to detect the double tap.</p>
  
  <p>I wanted 2 things to happen:</p>
  
  <ol>
  <li><p>When ever I double tap the screen, the animation should start and stop. And </p></li>
  <li><p>When I play with the volume rockers it will speed up the animation, even if the animation already started.</p></li>
  </ol>
  
  <p>So far here is my code for the double tap method:</p>
  
  <pre><code>private void doubleTapToScroll() {
      findViewById(R.id.minchaScroll).setOnTouchListener(new View.OnTouchListener() {
          private GestureDetector gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
              @Override
              public boolean onDoubleTap(MotionEvent e) {
                  mScrollView.post(new Runnable() {
                      @Override
                      public void run() {
  
                          //  while(mScrollView.getScrollY() &lt;= findViewById(R.id.alenuPart3).getBottom()){
                          //      audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                          //      int currentVolume = audio.getStreamVolume(AudioManager.STREAM_RING);
                          //      ObjectAnimator.ofInt(mScrollView, "scrollY", (findViewById(R.id.minchaLinearLayout)).getBottom()).setDuration(currentVolume*100000).start();
                          //  }
                          audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                          int currentVolume = audio.getStreamVolume(AudioManager.STREAM_RING);
                          ObjectAnimator animator = ObjectAnimator.ofInt(mScrollView, "scrollY", (findViewById(R.id.minchaLinearLayout)).getBottom()).setDuration(currentVolume * 10000);
  
                          autoScrollOn = !autoScrollOn;
  
                          if (animator.isRunning()) {
                              animator.start();
                          } else {
                              animator.cancel();
                          }
  
                          Log.d("In Run Method", String.valueOf(autoScrollOn));
                      }
                  });
                  return super.onDoubleTap(e);
              }
          });
  </code></pre>
  
  <p>I am working on part 1 for now, for some reason the animation will not pause.</p>
  
  <p>Also for part 2, I already take in the volume level and if I change it before the animation starts it works at different speeds, I am in the process of trying to make the speed change while the animation is on with a while loop and restarting the animation, but I don't think that would be the ideal way, any ideas?</p>
  
  <p>Thanks!</p>
  
  <p>Update: I tried, <code>.pause, .end and mScrollView.clearAnimation();</code> (not sure if that is even a good thought)</p>