0

I have a animation where it moves to the right when I click on it. But, when I try to click on it again I have to click on it at same the spot it was at before.

How can I fix this and Where it will be able to click on it at it's new location?

Here's my code

   public void sideBar()
   {

       ImageView sidebar = (ImageView)findViewById(R.id.sidebar);

       if(out == 0)
       {
       mSlideInRight = AnimationUtils.loadAnimation(this, R.anim.slide_in_right);
       mSlideInRight.setFillAfter(true);
       sidebar.startAnimation(mSlideInRight);
       out= 1;
       }
       else if(out == 1)
       {
               mSlideInLeft = AnimationUtils.loadAnimation(this, R.anim.slide_in_left);
               sidebar.startAnimation(mSlideInLeft);
               out=0;
       }

   }
RajeshVijayakumar
  • 10,281
  • 11
  • 57
  • 84
Dalton
  • 27
  • 6

1 Answers1

2

This happens because the ImageView itself hasn't "actually" moved. You have to implement an animation listener and move the ImageView at the end of the animation.

Please refer this question: Android Animation Flicker and this: Android Button Doesn't Respond After Animation

Community
  • 1
  • 1
JiTHiN
  • 6,548
  • 5
  • 43
  • 69