Android 无持续时间的旋转想象
伙计们。我有这个代码(异步任务) my animation()函数:Android 无持续时间的旋转想象,android,animation,rotation,Android,Animation,Rotation,伙计们。我有这个代码(异步任务) my animation()函数: public void animation() { int currentRotation = 0; anim = new RotateAnimation(currentRotation, (360*4), Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
public void animation()
{
int currentRotation = 0;
anim = new RotateAnimation(currentRotation, (360*4),
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
currentRotation = (currentRotation + 45) % 360;
anim.setInterpolator(new LinearInterpolator());
anim.setDuration(4000);// i want rotating without this <------------------
anim.setFillEnabled(true);
anim.setFillAfter(true);
refresh.startAnimation(anim);
}
在某处refresh.clearAnimation()停止动画的代码>
这工作对我来说太完美了。。如果这里有什么不对劲,请告诉我。。无论如何,谢谢你的回答:)我想你应该看看重复模式。持续时间是动画中一个循环的时间,如果将其设置为在此之后重复,则可以永远继续。见和
例如,您可以使用:
anim.setRepeatCount(Animation.INFINITE);
anim.setRepeatMode(Animation.RESTART);
anim.setRepeatCount(Animation.INFINITE);
anim.setRepeatMode(ValueAnimator.RESTART); //note the difference here
正如Pearsonatphoto所建议的,您应该查看重复模式。持续时间是动画中一个循环的时间,如果将其设置为在此之后重复,则可以永远继续
使用ObjectAnimator获得结果。
例如,您可以使用:
anim.setRepeatCount(Animation.INFINITE);
anim.setRepeatMode(Animation.RESTART);
anim.setRepeatCount(Animation.INFINITE);
anim.setRepeatMode(ValueAnimator.RESTART); //note the difference here