0

working in android last couple of days and i am trying to rotate an arrow by pressing a button. Using RotateAnimation and:

setFillAfter(true);

arrow remains in last position as supposed to. But when i press button again arrow yes starts to rotate from initial position, but there is also the "previous" arrow from the last call of animation which is finally overlapped by "new" arrow. So i guess i need to somehow reset/clear the setFillAfter but i can't find a way.

My code goes like this:

//Animation start
float Xaxis=0.835366f;
float Yaxis=0.676692f;
RotateAnimation rotateAnimation1 = new RotateAnimation(0, 180,
    Animation.RELATIVE_TO_SELF, Xaxis,Animation.RELATIVE_TO_SELF, Yaxis);
rotateAnimation1.setInterpolator(new LinearInterpolator());
rotateAnimation1.setDuration(2500);
rotateAnimation1.setRepeatCount(0);
image.startAnimation(rotateAnimation1);
rotateAnimation1.setAnimationListener(this);

@Override
public void onAnimationEnd(Animation animation) {
    animation.setFillAfter(true);
}

Any ideas would be usefull.. I have tried invalidate, clearAnimation to image, setting fillafter to false, reset on animation but still same.

Panos Karampis
  • 557
  • 6
  • 18
  • you have to change your arrow position in onAnimationEnd yourself , yes! you set setFillAfter(true); but the position that show after animate isn't real position of arrow – Intathep Mar 05 '13 at 16:44
  • and call setAnimationListener(this); before startAnimation – Intathep Mar 05 '13 at 16:45
  • `setFillBefore` makes arrow go to initial position. i want to stay at end of animation and when press button again do the whole animation with previous "frame" removed/resetted. – Panos Karampis Mar 05 '13 at 16:46
  • i don't get your point Intathep, arrow starts the (correct) initial position everytime i press button. Why change position? – Panos Karampis Mar 05 '13 at 16:58

1 Answers1

0

It is fixed, emulator is configured with shared GPU and runs perfectly. Fast and without any remainings of previous animations.

Panos Karampis
  • 557
  • 6
  • 18