Example usage for android.view.animation TranslateAnimation TranslateAnimation

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

Introduction

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

Prototype

public TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType,
        float fromYValue, int toYType, float toYValue) 

Source Link

Document

Constructor to use when building a TranslateAnimation from code

Usage

From source file:Main.java

public static Animation outToTopAnimation() {
    Animation outToTop = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, -1.0f);
    outToTop.setDuration(350);/* w ww  . j a v a  2 s .  c  om*/
    outToTop.setInterpolator(new AccelerateInterpolator());
    return outToTop;
}

From source file:Main.java

public static Animation inFromTopAnimation() {

    Animation inFromTop = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);
    inFromTop.setDuration(350);/*from w ww  . j ava 2  s .c  o m*/
    inFromTop.setInterpolator(new AccelerateInterpolator());
    return inFromTop;
}

From source file:Main.java

public static Animation outToBottomAnimation() {
    Animation outToBottom = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, +1.0f);
    outToBottom.setDuration(350);//from   ww w. j  ava 2  s  .c o  m
    outToBottom.setInterpolator(new AccelerateInterpolator());
    return outToBottom;
}

From source file:Main.java

public static Animation inFromBottomAnimation() {
    Animation inFromBottom = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);
    inFromBottom.setDuration(350);//from  ww w .  j av a 2s  .c  o m
    inFromBottom.setInterpolator(new AccelerateInterpolator());
    return inFromBottom;
}

From source file:Main.java

public static Animation createShowTranslateAnimation() {
    final Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF,
            0.0f);/* w w w  .  j a  va 2s  . c  o m*/
    return animation;
}

From source file:Main.java

public static Animation createHiddenTranslateAnimation() {
    final Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            -1.0f);//  w w  w .  ja va  2s.c o  m
    return animation;
}

From source file:Main.java

public static Animation createShowTranslateAnimationOnX() {
    final Animation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f);/*w w w .  j  a  v  a  2s . c  o  m*/
    animation.setDuration(1500);
    return animation;
}

From source file:Main.java

/**
 * Get translate animation of PathButton.<br>
 * The visibility of path button and anchor view must be
 * {@link View#VISIBLE} or {@link View#INVISIBLE}.
 *
 * @param isOpen Is open for button/*from ww w  . j  ava 2 s  .  c o m*/
 * @param button Path button
 * @param anchor Control button
 * @return Animation
 */
public static Animation animOfPathButton(boolean isOpen, View button, View anchor) {
    int[] anchorL = new int[2];
    anchor.getLocationOnScreen(anchorL);
    int[] buttonL = new int[2];
    button.getLocationOnScreen(buttonL);
    int x = anchorL[0] - buttonL[0] + (anchor.getWidth() - button.getWidth()) / 2;
    int y = anchorL[1] - buttonL[1] + (anchor.getHeight() - button.getHeight()) / 2;
    TranslateAnimation anim = new TranslateAnimation(Animation.ABSOLUTE, isOpen ? x : 0, Animation.ABSOLUTE,
            isOpen ? 0 : x, Animation.ABSOLUTE, isOpen ? y : 0, Animation.ABSOLUTE, isOpen ? 0 : y);
    anim.setDuration(300);
    anim.setFillAfter(true);
    return anim;
}

From source file:Main.java

public static Animation outToLeftAnimation() {
    Animation outtoLeft = 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);
    outtoLeft.setDuration(250);//from ww w.  java  2s .  c om
    outtoLeft.setInterpolator(new AccelerateInterpolator());
    return outtoLeft;
}

From source file:Main.java

public static Animation inFromLeftAnimation() {
    Animation inFromLeft = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);
    inFromLeft.setDuration(250);//w  w w .j  a v a 2 s  .c o m
    inFromLeft.setInterpolator(new AccelerateInterpolator());
    return inFromLeft;
}