Example usage for android.view.animation TranslateAnimation setDuration

List of usage examples for android.view.animation TranslateAnimation setDuration

Introduction

In this page you can find the example usage for android.view.animation TranslateAnimation setDuration.

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:Main.java

public static Animation outToLeftAnimation(
        final android.view.animation.Animation.AnimationListener animationlistener) {
    final TranslateAnimation translateanimation = new TranslateAnimation(2, 0F, 2, -1F, 2, 0F, 2, 0F);
    translateanimation.setDuration(300L);
    translateanimation.setInterpolator(new AccelerateInterpolator());
    translateanimation.setAnimationListener(animationlistener);
    return translateanimation;
}

From source file:Main.java

public static Animation outToRightAnimation(
        final android.view.animation.Animation.AnimationListener animationlistener) {
    final TranslateAnimation translateanimation = new TranslateAnimation(2, 0F, 2, 1F, 2, 0F, 2, -1F);
    translateanimation.setDuration(300L);
    translateanimation.setInterpolator(new AccelerateInterpolator());
    translateanimation.setAnimationListener(animationlistener);
    return translateanimation;
}

From source file:Main.java

public static Animation getYTranslate(float fromYDelta, float toYDelta, long duration) {
    TranslateAnimation animation = new TranslateAnimation(0, 0, fromYDelta, toYDelta);
    animation.setFillAfter(true);//from   w  ww  .  ja  va 2 s  .  com
    animation.setDuration(duration);
    return animation;
}

From source file:Main.java

public static void twoPoint(ImageView imageview, float f, float f1, int i, int j) {
    TranslateAnimation translateanimation = new TranslateAnimation(0.0F, f, 0.0F, f1);
    translateanimation.setFillAfter(true);
    translateanimation.setDuration(j);
    imageview.startAnimation(translateanimation);
}

From source file:Main.java

public static Animation getTranslate(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
        long duration) {
    TranslateAnimation animation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
    animation.setFillAfter(true);/*from  www. j a  v  a2 s .  c  o  m*/
    animation.setDuration(duration);
    return animation;
}

From source file:Main.java

public static void translateY(final View view, float fromY, float toY, long duration) {
    if (Build.VERSION.SDK_INT >= 12) {
        if (duration == 0)
            view.setTranslationY(toY);//  w ww.j  a  v  a 2 s. c  o  m
        else
            view.animate().translationY(toY).setDuration(duration).start();
    } else {
        TranslateAnimation translate = new TranslateAnimation(0, 0, fromY, toY);
        translate.setDuration(duration);
        translate.setFillEnabled(true);
        translate.setFillBefore(true);
        translate.setFillAfter(true);
        addAnimation(view, translate);
    }
}

From source file:Main.java

private static TranslateAnimation trans(int fromXType, int fromXValue, int toXType, int toXValue, int fromYType,
        int fromYValue, int toYType, int toYValue) {
    TranslateAnimation anima = new TranslateAnimation(fromXType, fromXValue, toXType, toXValue, fromYType,
            fromYValue, toYType, toYValue);
    anima.setDuration(500);
    return anima;

}

From source file:Main.java

private static TranslateAnimation getTranslateX100To0Animation(View view, long duration) {
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1,
            Animation.RELATIVE_TO_SELF, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0);
    animation.setDuration(duration);
    return animation;
}

From source file:Main.java

private static TranslateAnimation getTranslateX0To100Animation(View view, long duration) {
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 1, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0);
    animation.setDuration(duration);
    return animation;
}

From source file:Main.java

/**
 *    move the background view(translate animation).
 * /*  ww w . j  av a 2  s  . com*/
 * @param view
 *          the view will be moved
 * @param durationMillis
 *          translate animation duration
 * @param fromX
 *          from X coordinate
 * @param toX
 *          to X coordinate
 * @param fromY
 *          from Y coordinate
 * @param toY
 *          to Y coordinate
 */
public static void translateFromAbove(final Context context, final View view, final long durationMillis,
        boolean fillAfter, float fromX, float toX, final float fromY, final float toY) {
    TranslateAnimation translateAnimation = new TranslateAnimation(fromX, toX, fromY, toY + 5);
    translateAnimation.setInterpolator(new BounceInterpolator());
    translateAnimation.setDuration(durationMillis);
    translateAnimation.setFillAfter(fillAfter);//this animation performed will persist when it is finished
    view.startAnimation(translateAnimation);
}