RotateAnimation没有持续时间

Pet*_*ter 6 animation android rotation

家伙.我有这个代码(asyncTask)

我的animation()函数:

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);
        }
Run Code Online (Sandbox Code Playgroud)

谁能告诉我没有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);
            }
Run Code Online (Sandbox Code Playgroud)

refresh.clearAnimation();停止动画的某个地方 它的工作对我来说很完美..如果这里有些不对劲 - 请告诉我..无论如何,谢谢你的答案:)

Pea*_*oto 11

我想你应该看看重复模式.持续时间是一个循环通过动画的时间,如果你将其设置为重复,那么它可以永远继续.看到这个那个.

例如,您可以使用:

anim.setRepeatCount(Animation.INFINITE);
anim.setRepeatMode(Animation.RESTART);
Run Code Online (Sandbox Code Playgroud)