1

我想制作一个包含多个项目的动画列表,每个项目都包含一个旋转标签。形成它的正确方法是什么?还有其他方法可以做到这一点吗?这是我的代码:

<?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 在结束时重复。请帮忙。

4

1 回答 1

2

请将旋转拆分为 2 个动画 xml 文件“rotate_0_50.xml”和“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);
于 2013-08-20T11:45:05.183 回答