动画的顺序播放

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:duration="800"
        android:fromYDelta="-100%"
        android:toYDelta="0" />
    <translate
        android:duration="800"
        android:fromYDelta="0"
        android:startOffset="1800"
        android:toYDelta="-100%" />

</set>

参数: startOffset表示,该动画延迟多长时间开始播放。   这样就能变现满足动画顺序播放的效果。

    public void popInfo() {
        Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.custom_home_text_info);
        textInfo.setVisibility(View.VISIBLE); //在播放动画之前, 要让该控件先显示出来, 否则有bug。
        anim.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }
            
            @Override
            public void onAnimationRepeat(Animation animation) {
                
            }
            
            @Override
            public void onAnimationEnd(Animation animation) {
                textInfo.setVisibility(View.GONE);
            }
        });
        textInfo.startAnimation(anim);
    }
原文地址:https://www.cnblogs.com/xitang/p/3180845.html