1

I have 2 views that are being animated by sliding in and out of the screen simultaniously

this is the code for it: How to animate a slide in notification view that pushes the content view down

However, when the animation slides in, i must clear the animation, in order for the click events to work properly, otherwise they are also translated (which is not what i want)

What do i need to put in onAnimationEnd in the listener in order to clear the animation and have the view remain the way it looks after it has been animated

this is my current code:

greenViewSlideIn(1500, 0, new AnimatorListener() {

                @Override
                public void onAnimationStart(Animator animation) {
                    greenView.setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationRepeat(Animator animation) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onAnimationEnd(Animator animation) {

                    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(blueView.getWidth(), blueView.getHeight());
                    layoutParams.setMargins(blueView.getLeft(), blueView.getTop() - greenViewHeight, blueView.getRight(), blueView.getBottom());
                    blueView.setLayoutParams(layoutParams);
                    greenView.clearAnimation();
//                  blueView.clearAnimation();

                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    // TODO Auto-generated method stub

                }
            });
Community
  • 1
  • 1
Lena Bru
  • 13,521
  • 11
  • 61
  • 126

1 Answers1

0

Two things you can do:

  1. Make sure the setFillAfter flag on the animation is set to false. Then there's no need to an AnimationListener

  2. Once the animation ends, call view.setAnimation(null);

Hope this helps :)

Gil Moshayof
  • 16,633
  • 4
  • 47
  • 58
  • 1
    this does not help - because after the blue view is done being animated, blueView.setAnimation(null); makes it go back to the starting position - how do i make it stay where it is ? – Lena Bru Oct 07 '13 at 12:35