2017-02-24 89 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)不確定:) :)