安卓(Android) 怎么实现先小再大动画(Animation)

2019年10月15日21:39:03安卓(Android) 怎么实现先小再大动画(Animation)已关闭评论 354 1009字阅读3分21秒

1.简介

安卓(Android) 怎么实现先小再大动画(Animation)?——请看下文。

2.示例代码

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



import android.view.View;

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

public class Main {
    public static void smallThenBig(View animationView,
            Animation.AnimationListener animationListener) {
        AnimationSet animationSet = new AnimationSet(true);
        ScaleAnimation smallAnimation = new ScaleAnimation(1f, (float) 0.8,
                1f, (float) 0.8, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        smallAnimation.setDuration(80);
        smallAnimation.setFillAfter(false);
        animationSet.addAnimation(smallAnimation);

        ScaleAnimation bigAnimation = new ScaleAnimation((float) 1.2, 1f,
                (float) 1.2, 1f, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        bigAnimation.setDuration(160);
        bigAnimation.setStartOffset(80);
        bigAnimation.setFillAfter(false);
        animationSet.addAnimation(bigAnimation);
        animationSet.setAnimationListener(animationListener);
        animationView.startAnimation(animationSet);
    }
}

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