android旋转动画在中断时获取当前角度/度数

标签 android animation rotation angle degrees

我想知道当动画结束或中断时如何获取旋转动画的当前角度/度数?

我的想法是,当单击某个按钮时动画被中断时,旋转将逆时针旋转(当前流程为顺时针),从中断时的最后一个角度/度数开始。

我尝试过使用 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/

相关文章:

c - 无限动画正弦波

java - Android 将 unix 时间戳设置为 DatePicker

android - 无法得到 smack 的响应

iphone - 解雇ModalViewController与过渡: left to right

google-chrome - Webkit 变换在 Webkit 动画中不起作用

html - 为什么div和旋转的div(三 Angular 形)之间有间隙

rotation - 在处理中旋转、反转和平移 PShape 对象

android - 如何在不使用 <add-resource> 的情况下将多个 -S 值与 aapt 一起使用?

android - 严格模式 + 分析

ios - 旋转 UILabel