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 void startTranslationAnimation(View view) {
    TranslateAnimation translateAnimation = new TranslateAnimation(-50f, 50f, 0, 0);
    translateAnimation.setDuration(1000);
    translateAnimation.setRepeatCount(Animation.INFINITE);
    translateAnimation.setRepeatMode(Animation.REVERSE);
    view.setAnimation(translateAnimation);
    translateAnimation.start();//from ww w. ja  va 2  s  .c o  m
}

From source file:Main.java

/**
 *    move the background view(translate animation).
 * //from  w  w w. ja  v a  2s. c om
 * @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 translate(View view, long durationMillis, boolean fillAfter, float fromX, float toX,
        float fromY, float toY) {
    TranslateAnimation ta = new TranslateAnimation(fromX, toX, fromY, toY);
    ta.setDuration(durationMillis);
    ta.setFillAfter(fillAfter);//this animation performed will persist when it is finished
    view.startAnimation(ta);
}

From source file:Main.java

public static AnimationSet ShuffleAnimation(int deltaX, int deltaY) {

    TranslateAnimation shake_1 = new TranslateAnimation(0, deltaX, 0, deltaY);
    shake_1.setDuration(400);
    shake_1.setStartOffset(0);//from ww  w .  j  a  v a  2  s  . co m
    shake_1.setFillAfter(true);
    TranslateAnimation shake_2 = new TranslateAnimation(0, -deltaX, 0, -deltaY);
    shake_2.setDuration(400);
    shake_2.setStartOffset(400);
    shake_2.setFillAfter(true);
    AnimationSet ShakeIt = new AnimationSet(true);
    ShakeIt.addAnimation(shake_1);
    ShakeIt.addAnimation(shake_2);
    ShakeIt.setInterpolator(new OvershootInterpolator());

    return ShakeIt;
}

From source file:Main.java

public static Animation getTranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta,
        float toYDelta, long durationMillis) {
    TranslateAnimation translate = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
    translate.setDuration(durationMillis);
    translate.setFillAfter(true);/*from   www  .j a  va  2 s  . co  m*/
    return translate;
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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