我正在尝试创建一个在 imageview 中旋转图像的动画。这种旋转必须增加它的速度(所以持续时间)每次重复,直到持续时间小于一个值。
我试过的是:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/my_logo"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"
android:repeatMode="restart"
android:repeatCount="10"
android:toDegrees="360">
</rotate>
活动中:
logo = (ImageView) findViewById(R.id.imageViewToRotate);
rotation = AnimationUtils.loadAnimation(this, R.anim.first_animation_splash);
rotation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
if(animation.getDuration()>100)
animation.setDuration(animation.getDuration()/2);
else
logo.clearAnimation();
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
}
});
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(hasFocus){
logo.startAnimation(rotation);
}
}
但它继续以相同的持续时间旋转 10 次....我该如何解决?谢谢!