2

i wonder how to get current angle / degrees in rotate animation when animation ends or gets interrupted?

my idea is when the animation gets interrupted when some button is clicked, the rotation will go counter-clockwise (current flow is clockwise), start from last angle /degree right when it gets interrupted.

i've tried using applyTransformation, but it seems not called :(

thanks!

yfsx
  • 1,906
  • 14
  • 17

1 Answers1

4

For this you must have to rotate your object not with simple rotate animation. But Need to rotate with ObjectAnimator.

Here is simple example to find rotation angle of ball(imageview) .

ImageView  ball;

int i = ball.getMeasuredHeight();

ObjectAnimator animation = ObjectAnimator.ofFloat(ball, "rotation", 0, 360);
animation.setDuration(10000);
ball.setPivotX(0);
ball.setPivotY(i / 2);
animation.setRepeatCount(ObjectAnimator.INFINITE);
animation.setInterpolator(new LinearInterpolator());
animation.start();

To get current rotation angle use:

ball.getRotation();
Idan
  • 5,405
  • 7
  • 35
  • 52
Sanket Sangani
  • 253
  • 3
  • 10