2017-02-24 75 views
-2

你好,我想是想不停我怎么办呢旋转动画没有停止

<rotate 
    android:repeatCount="infinite" 
    android:fromDegrees="0" 
    android:toDegrees="360" 
    android:pivotX="50%" 
    android:pivotY="50%" 
    android:duration="3000" 

    /> 
+0

欢迎来到堆栈溢出,请阅读[我如何问一个好问题?](http://stackoverflow.com/help/how-to-ask)。 –

回答

0

你可能想看看这个post。 尝试以下操作:

RotateAnimation rotateAnimation = new RotateAnimation(30, 90, 
        Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
rotateAnimation.setRepeatCount(Animation.INFINITE); 
rotateAnimation.setRepeatMode(Animation.RESTART); 

那么动画设置为对象要旋转:

yourObject.startAnimation(rotateAnimation); 
+0

我没有改变任何东西,我希望她继续旋转而不停止 –

+0

对不起,如果不知道你想要什么,很难提供帮助。你需要提供更多的代码和更多的信息来描述你现在所拥有的和你想要的问题。 – skbrhmn

+0

我的朋友尝试在顶部的代码,你会看到它旋转并停止 但我不想他停止 –

0

下面就用这个代码:)

 RotateAnimation rotate = new RotateAnimation(0, BladeRotateAngle, 
    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
    rotate.setDuration(5000); 
    rotate.setInterpolator(new LinearInterpolator()); 
    rotate.setRepeatCount(Animation.INFINITE); 
    Object.startAnimation(rotate); 

没有线,动画在每个循环后停止:

 rotate.setInterpolator(new LinearInterpolator()); 

那么容易:)))......现在,如果你需要一个动画与 - >软启动< - 和无限循环,使用如下代码:

 final RotateAnimation[] rotate = {new RotateAnimation(0, 180, 
    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f)}; 
    rotate[0].setDuration(3500); 
    rotate[0].setInterpolator(new AccelerateInterpolator()); 
    rotate[0].setRepeatCount(Animation.INFINITE); 
    Object.startAnimation(rotate[0]); 


    new Handler().postDelayed(new Runnable() { 
     @Override 
     public void run() { 

      rotate[0] = new RotateAnimation(180, 540, 
      Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
      rotate[0].setDuration(4000); 
      rotate[0].setInterpolator(new LinearInterpolator()); 
      rotate[0].setRepeatCount(Animation.INFINITE); 
      Object.clearAnimation(); 
      Object.startAnimation(rotate[0]); 
     } 
    } , 3500); 

正如你所看到的,第一个动画效果,导致对象从0度到180度平滑地旋转(加速),然后第二个动画导致对象从180度旋转到540度(一个lape)不确定:) :)