安卓(Android) 怎么获取纵向单击动画(Animation)

2019年10月16日22:57:11安卓(Android) 怎么获取纵向单击动画(Animation)已关闭评论 165 1401字阅读4分40秒

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.DecelerateInterpolator;
import android.view.animation.Interpolator;

import android.view.animation.TranslateAnimation;

public class Main {

    public static Animation getPortraitClickAnimation() {
        AnimationSet set = new AnimationSet(false);
        set.setFillEnabled(true);
        set.setFillAfter(true);

        Animation animationRightToLeft = new TranslateAnimation(
                Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF,
                -0.2f, Animation.RELATIVE_TO_SELF, 0,
                Animation.RELATIVE_TO_SELF, 0);
        animationRightToLeft.setFillEnabled(true);
        animationRightToLeft.setFillAfter(true);
        Interpolator ait = new AccelerateInterpolator(1.5f);
        animationRightToLeft.setInterpolator(ait);
        animationRightToLeft.setDuration(400);

        Animation animationLeftToSelf = new TranslateAnimation(
                Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF,
                0.2f, Animation.RELATIVE_TO_SELF, 0,
                Animation.RELATIVE_TO_SELF, 0);
        animationLeftToSelf.setFillEnabled(true);
        animationLeftToSelf.setFillAfter(true);
        Interpolator dit = new DecelerateInterpolator(1.5f);
        animationLeftToSelf.setInterpolator(dit);
        animationLeftToSelf.setStartOffset(400);
        animationLeftToSelf.setDuration(300);

        set.addAnimation(animationRightToLeft);
        set.addAnimation(animationLeftToSelf);
        return set;
    }
}

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