安卓(Android) 怎么返回将目标对象从其中心向两边缩放,直到从给定的对象中达到给定值为止

2019年10月15日21:31:59安卓(Android) 怎么返回将目标对象从其中心向两边缩放,直到从给定的对象中达到给定值为止已关闭评论 299 1311字阅读4分22秒

1.简介

安卓(Android) 怎么返回将目标对象从其中心向两边缩放,直到从给定的对象中达到给定值为止?——请看下文。

2.示例代码

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



import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

import android.view.animation.Interpolator;
import android.view.animation.ScaleAnimation;

public class Main {
    
     
    public static Animation Scale(float from, float to, int duration) {
        return Scale(from, to, duration, null);
    }

    
    public static Animation Scale(float from, float to, int duration,
            Interpolator interpolation) {
        return Scale(from, to, from, to, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f, duration, interpolation,
                null);
    }

    
    public static Animation Scale(float from, float to, int duration,
            Interpolator interpolation, AnimationListener listener) {
        return Scale(from, to, from, to, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f, duration, interpolation,
                listener);
    }

    
    public static Animation Scale(float fromX, float toX, float fromY,
            float toY, int pivotXType, float pivotXValue, int pivotYType,
            float pivotYValue, int duration, Interpolator interpolation,
            AnimationListener listener) {
        ScaleAnimation animation = new ScaleAnimation(fromX, toX, fromY,
                toY, pivotXType, pivotXValue, pivotYType, pivotYValue);
        animation.setDuration(duration);

        if (interpolation != null)
            animation.setInterpolator(interpolation);

        if (listener != null) {
            animation.setAnimationListener(listener);
        }

        return animation;
    }
}

 
继续阅读