安卓(Android) 怎么缩放动画(ScaleAnimation)

2019年10月15日21:19:02安卓(Android) 怎么缩放动画(ScaleAnimation)已关闭评论 342 1444字阅读4分48秒

1.简介

安卓(Android) 怎么缩放动画(ScaleAnimation)?——请看下文。

2.示例代码

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


import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

public class Main {
    public static void animationScale(View paramView) {
        animation(paramView, new ScaleAnimation(0.0F, 1.0F, 0.0F, 1.0F, 2,
                0.5F, 2, 0.5F), 1000L, 0L);
    }

    public static void animationScale(View paramView, long paramLong,
            Animation.AnimationListener paramAnimationListener) {
        ScaleAnimation localScaleAnimation = new ScaleAnimation(0.0F, 1.0F,
                0.0F, 1.0F, 1, 0.5F, 1, 0.5F);
        localScaleAnimation.setAnimationListener(paramAnimationListener);
        animation(paramView, localScaleAnimation, paramLong, 0L);
    }

    private static void animation(View paramView, Animation paramAnimation,
            long paramLong1, long paramLong2) {
        paramAnimation.setDuration(paramLong1);
        paramAnimation.setStartOffset(paramLong2);
        paramView.setVisibility(0);
        paramView.startAnimation(paramAnimation);
    }

    public static void animation(View paramView) {
        TranslateAnimation localTranslateAnimation = new TranslateAnimation(
                2, 1.0F, 2, 0.0F, 2, 0.0F, 2, 0.0F);
        AlphaAnimation localAlphaAnimation = new AlphaAnimation(0.0F, 1.0F);
        AnimationSet localAnimationSet = new AnimationSet(false);
        localAnimationSet.addAnimation(localTranslateAnimation);
        localAnimationSet.addAnimation(localAlphaAnimation);
        animation(paramView, localAnimationSet, 1000L, 0L);
    }
}

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