【问题标题】:android rotate animation get current angle / degrees when interruptedandroid旋转动画在中断时获取当前角度/度数
【发布时间】:2015-09-14 09:37:58
【问题描述】:

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

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

我尝试过使用 applyTransformation,但它似乎没有被调用:(

谢谢!

【问题讨论】:

  • applyTransformation 被调用用于扩展android.view.animation.Animation的任何动画
  • 我会记住@pskink 谢谢!
  • 请参考这个question

标签: android animation rotation angle degrees


【解决方案1】:

为此,您必须不使用简单的旋转动画来旋转对象。 但需要用 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();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-01
    • 2011-03-21
    • 2015-08-23
    • 1970-01-01
    • 2017-09-16
    相关资源
    最近更新 更多