Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无持续时间的旋转想象_Android_Animation_Rotation - Fatal编程技术网

Android 无持续时间的旋转想象

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,

伙计们。我有这个代码(异步任务)

my 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);
        }
在某处
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