你好我想不停地怎么做
<rotate
android:repeatCount="infinite"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="3000"
/>
答案 0 :(得分: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);
答案 1 :(得分:0)
只需使用此代码:)
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);
如此简单:)))...现在,如果你需要一个带有 - &gt;软启动&lt; - 和无限循环的动画,请使用下面的代码:
exit()
正如您所看到的,第一个动画效果会使对象从0度到180度平滑(加速)旋转,然后第二个动画会使对象从180度到540度(一个lape)不加速地旋转:)