2013-04-04 131 views
0

我创建了一个轮子旋转动画,当我运行应用程序时它会自动运行...我希望它旋转90度并暂停一会儿,然后再旋转90度,直到它达到360%.. 。这里是我的代码::在android中旋转动画

public void Start(){ 
    RotateAnimation counterSpinW = new RotateAnimation(0f, 90f, 50,50); 
    counterSpinW.setRepeatMode(1); 
    counterSpinW.getFillAfter(); 
    counterSpinW.setDuration(8000); 

    counterSpinW.setInterpolator(new LinearInterpolator()); 
    bigLayout.startAnimation(counterSpinW); 

    RotateAnimation counterSpinW2 = new RotateAnimation(0f, 90f, 50,50); 
    counterSpinW2.setRepeatMode(1); 
    counterSpinW2.getFillAfter(); 
    counterSpinW2.setDuration(8000); 
    counterSpinW2.setInterpolator(new LinearInterpolator()); 
    bigLayout.startAnimation(counterSpinW2); 

    RotateAnimation counterSpinW3 = new RotateAnimation(0f, 90f, 50,50); 
    counterSpinW3.setRepeatMode(1); 
    counterSpinW3.getFillAfter(); 
    counterSpinW3.setDuration(8000); 
    counterSpinW3.setInterpolator(new LinearInterpolator()); 
bigLayout.startAnimation(counterSpinW3); 

RotateAnimation counterSpinW4 = new RotateAnimation(0f, 90f, 50,50); 
counterSpinW4.setRepeatMode(-1); 
counterSpinW4.getFillAfter(); 
counterSpinW4.setDuration(8000); 
counterSpinW4.setInterpolator(new LinearInterpolator()); 
bigLayout.startAnimation(counterSpinW4); 

我想,也许这不会work..but我从来没有测试尚未....

+0

所有我尊重我认为使用xml进行annimation更好一个硬编码。 – Smartoop 2013-04-04 23:34:16

回答

0

你应该使用setStartOffset()

firstRotateAnimation.setStartOffset(0); 
pauseAnimation.setStartOffset(8000); 
newRotateAnimation.setStartOffset(16000); 
+0

我应该在哪里放这个代码???我该怎么改? – 2013-04-04 23:34:56