安卓(Android) 怎么从右侧动画(Animation)返回主片段

2019年10月15日20:58:15安卓(Android) 怎么从右侧动画(Animation)返回主片段已关闭评论 280 832字阅读2分46秒

1.简介

安卓(Android) 怎么从右侧动画(Animation)返回主片段?——请看下文。

2.示例代码

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



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

import android.view.animation.TranslateAnimation;

public class Main {
    static public Animation mainFragmentBackFromRight(int distance) {

        AnimationSet animationSet = new AnimationSet(true);

        Animation step1 = new TranslateAnimation(Animation.ABSOLUTE,
                distance, Animation.ABSOLUTE, 720, Animation.ABSOLUTE, 0,
                Animation.ABSOLUTE, 0);
        step1.setDuration(200);

        Animation step2 = new TranslateAnimation(Animation.ABSOLUTE, 100,
                Animation.ABSOLUTE, -720, Animation.ABSOLUTE, 0,
                Animation.ABSOLUTE, 0);
        step2.setDuration(400);

        animationSet.addAnimation(step1);
        animationSet.addAnimation(step2);
        animationSet.setInterpolator(new BounceInterpolator());
        return animationSet;

    }
}

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