安卓(Android) 怎么快速添加事件显示动画(Animation)

2019年10月16日23:24:22安卓(Android) 怎么快速添加事件显示动画(Animation)已关闭评论 255 987字阅读3分17秒

1.简介

安卓(Android) 怎么快速添加事件显示动画(Animation)?——请看下文。

2.示例代码

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



import android.view.animation.AccelerateInterpolator;

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

import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

public class Main {
    private final static long QUICK_ADD_ANIMATION_DURATION = 500;

    static public Animation quickAddEventShow(float yValue) {

        AnimationSet animationSet = new AnimationSet(true);

        ScaleAnimation scale = new ScaleAnimation(1.0f, 1.0f, 0.125f, 1.0f); 
        scale.setDuration(QUICK_ADD_ANIMATION_DURATION);
        scale.setInterpolator(new AccelerateInterpolator());
        animationSet.addAnimation(scale);

        TranslateAnimation a = new TranslateAnimation(
                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f,

                Animation.ABSOLUTE, yValue, Animation.RELATIVE_TO_PARENT,
                0.0f);
        a.setDuration(QUICK_ADD_ANIMATION_DURATION);
        a.setInterpolator(new AccelerateInterpolator());
        animationSet.addAnimation(a);

        return animationSet;

    }
}

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