伙计们。我有这个代码(asyncTask)
我的动画()函数:
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);
}有人能告诉我,没有anim.setDuration也是可能的吗?才刚刚开始..例如,当我按下按钮时,动画就停止了。请帮帮我。打招呼,彼得。
最终代码:
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);
// anim.setRepeatMode(Animation.INFINITE);
anim.setRepeatCount(Animation.INFINITE);
anim.setFillEnabled(true);
anim.setFillAfter(true);
refresh.startAnimation(anim);
}和某处refresh.clearAnimation();的停止动画,它是我的工作完美..如果这里有什么问题-请告诉我..无论如何,感谢您的回答:)
发布于 2011-06-02 21:26:57
我认为你应该看看重复模式。持续时间是在动画中循环一次的时间,如果您将其设置为在此之后重复,则它可以永远继续下去。参见this和that。
例如,您可以使用:
anim.setRepeatCount(Animation.INFINITE);
anim.setRepeatMode(Animation.RESTART);发布于 2017-11-01 13:26:31
正如PearsonArtPhoto建议的那样,您应该查看重复模式。持续时间是在动画中循环一次的时间,如果您将其设置为在此之后重复,则它可以永远继续下去。
使用ObjectAnimator来实现效果。例如,您可以使用:
anim.setRepeatCount(Animation.INFINITE);
anim.setRepeatMode(ValueAnimator.RESTART); //note the difference herehttps://stackoverflow.com/questions/6215074
复制相似问题