安卓(Android) 怎么创建飞出到底部的Alpha动画(Animation)

2019年10月15日19:54:29安卓(Android) 怎么创建飞出到底部的Alpha动画(Animation)已关闭评论 281 1011字阅读3分22秒

1.简介

安卓(Android) 怎么创建飞出到底部的Alpha动画(Animation)?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */


import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;

import android.view.animation.TranslateAnimation;

public class Main {
    public static Animation outToBottomAlphaAnimation() {
        AnimationSet set = new AnimationSet(true);

        set.addAnimation(outToBottomAnimation());
        set.addAnimation(outAlphaAnimation());

        return set;
    }

    public static Animation outToBottomAnimation() {
        Animation outtoLeft = new TranslateAnimation(
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, +1.0f);
        outtoLeft.setDuration(350);
        outtoLeft.setInterpolator(new AccelerateInterpolator());
        return outtoLeft;
    }

    public static Animation outAlphaAnimation() {
        AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
        alpha.setDuration(1000);
        alpha.setInterpolator(new AccelerateInterpolator());
        return alpha;
    }
}

 
继续阅读
编程十万个怎么办