安卓(Android) 怎么实现从右到右动画(Animation)

2019年10月15日20:59:55安卓(Android) 怎么实现从右到右动画(Animation)已关闭评论 385 907字阅读3分1秒

1.简介

安卓(Android) 怎么实现从右到右动画(Animation)?——请看下文。

2.示例代码

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



import android.view.animation.AccelerateInterpolator;

import android.view.animation.Animation;

import android.view.animation.TranslateAnimation;

public class Main {
    static public Animation outToRightAnimation() {

        Animation outtoRight = new TranslateAnimation(

        Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
                +1.0f,

                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f

        );

        outtoRight.setDuration(200);

        outtoRight.setInterpolator(new AccelerateInterpolator());

        return outtoRight;

    }

    static public Animation outToRightAnimation(int duration) {

        Animation outtoRight = new TranslateAnimation(

        Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
                +1.0f,

                Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_PARENT, 0.0f

        );

        outtoRight.setDuration(duration);

        outtoRight.setInterpolator(new AccelerateInterpolator());

        return outtoRight;

    }
}

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