title: Android Animation Flicker
body: <p>I've been trawling through as many threads on this topic that I can find on the flicker that arises in Android 2.2 when dealing with AnimationListeners, but I can't quite solve my issue. </p>
  
  <p>What I've got is a LinearLayout 'popover' that the user touches to move down about 100 pixels, and touches again to move it back up. I've finally got it working on the first part without any flicker (thanks to the suggestion to call clearAnimation() on the view being animated), but when doing the opposite (ie, moving the view back up), there's a flicker at the start. I can't really call clearAnimation() in the onAnimationStart() method as it won't animate! </p>
  
  <p>Of course, all animation works perfectly if I used setFillAfter() without any animation listener, but then the view's touch area won't move (because the view itself hasn't "actually" moved). </p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <pre><code>this.popoverTab.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
          popoverTab.setClickable(false);
          popoverTab.setFocusable(false);
          if (popoverHidden) {
              Log.d(TAG, "About to show popover");
              // the popover is currently hidden, show it.
              TranslateAnimation animation = new TranslateAnimation(0, 0, 100, 0);
              animation.setDuration(700);
              animation.setFillBefore(true);
              animation.setAnimationListener(new AnimationListener() {
                  public void onAnimationEnd(Animation animation) {
  
                  }
  
                  public void onAnimationRepeat(Animation animation) {
  
                  }
  
                  public void onAnimationStart(Animation animation) {
                      footer.layout(footer.getLeft(), (footer.getTop() - 100), footer.getRight(), footer.getBottom());
                  }
              });
              footer.startAnimation(animation);
          } else {
              Log.d(TAG, "About to hide popover");
              // the popover is showing, hide it.
              TranslateAnimation animation = new TranslateAnimation(0, 0, 0, 100);
              animation.setDuration(700);
              animation.setFillAfter(true);
              animation.setAnimationListener(new AnimationListener() {
                  public void onAnimationEnd(Animation animation) {
                      footer.clearAnimation();
                      footer.layout(footer.getLeft(), (footer.getTop() + 100), footer.getRight(), footer.getBottom());
                  }
  
                  public void onAnimationRepeat(Animation animation) {
  
                  }
  
                  public void onAnimationStart(Animation animation) {
  
                  }
              });
              footer.startAnimation(animation);
          }
          // invert.
          popoverHidden = !popoverHidden;
          popoverTab.setClickable(true);
          popoverTab.setFocusable(true);
      }
  
  });
  </code></pre>