在android中旋转动画

时间:2013-04-04 23:26:09

标签: android android-layout android-widget android-animation

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

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);

我想也许这不会奏效..但我从未测试过它......

1 个答案:

答案 0 :(得分:0)

你应该使用setStartOffset()

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