我想制作一个包含多个项目的动画列表,每个项目都包含一个旋转标记。形成它的正确方法是什么?还有其他方法可以做同样的事情吗?这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<rotate
android:interpolator="@android:anim/linear_interpolator"
android:repeatMode="restart"
android:fromDegrees="0"
android:toDegrees="50"
android:pivotX="301"
android:pivotY="334"
android:duration="1000"
android:startOffset="0"
/>
<rotate
android:interpolator="@android:anim/linear_interpolator"
android:repeatMode="restart"
android:fromDegrees="50"
android:toDegrees="20"
android:pivotX="301"
android:pivotY="334"
android:duration="859"
android:startOffset="0"
/>
</set>
我希望这个xml在结束时重复。请帮忙。
答案 0 :(得分:2)
请将旋转拆分为2个动画xml文件“rotate_0_50.xml”&amp; “rotate_50_20.xml”并尝试以下代码:
final Animation anim0_50 = AnimationUtils.loadAnimation(this, R.anim.rotate_0_50);
final Animation anim50_20 = AnimationUtils.loadAnimation(this, R.anim.rotate_50_20);
final View animView = findViewById(R.id.anim_view)
anim0_50.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
animView.startAnimation(anim50_20);
}
});
anim50_20.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
animView.startAnimation(anim0_50);
}
});
animView.startAnimation(anim0_50);