java Android查看旋转动画并设置旋转未按预期工作
我试图将视图旋转90度,但每次调用此方法时,视图会向前跳90度,然后再旋转90度
我试着玩数字游戏,但没有成功。这段代码的工作原理似乎有些我不明白的地方
有人能解释一下目前正在发生的事情,以及为了达到预期的效果需要做哪些改变吗
public void RotatePoint(float toDegrees) {
final RotateAnimation rotate =
new RotateAnimation(pt.getRotation(), pt.getRotation() + toDegrees,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(1000);
rotate.setFillEnabled(true);
rotate.setFillAfter(true);
pt.startAnimation(rotate);
pt.setRotation(pt.getRotation()+toDegrees);
if (pt.getRotation() == 360) {
pt.setRotation(0);
}
}
# 1 楼答案
取全局变量-float rotation=0,fromRotation=0
在Onclick上
和旋转点(浮动到角度)