我想知道当动画结束或中断时如何获取旋转动画的当前角度/度数?
我的想法是,当单击某个按钮时动画被中断时,旋转将逆时针旋转(当前流程为顺时针),从中断时的最后一个角度/度数开始。
我尝试过使用 applyTransformation,但它似乎没有被调用:(
谢谢!
最佳答案
为此,您必须旋转对象,而不是使用简单的旋转动画。 但需要用ObjectAnimator来旋转。
这是查找球(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();
要获取当前旋转角度,请使用:
ball.getRotation();
关于android旋转动画在中断时获取当前角度/度数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32561564/