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 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(OUT_DURATION);
    outtoLeft.setInterpolator(new AccelerateInterpolator());
    return outtoLeft;
}

From source file:Main.java

public static 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(OUT_DURATION);
    outtoRight.setInterpolator(new AccelerateInterpolator());
    return outtoRight;
}

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(DURATION);/*from  w w  w . jav a2 s.com*/
    inFromLeft.setInterpolator(new AccelerateDecelerateInterpolator());
    return inFromLeft;
}

From source file:Main.java

public static Animation inFromRightAnimation() {

    Animation inFromRight = 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);
    inFromRight.setDuration(DURATION);/*  w  w w . ja  va  2  s.  c  o  m*/
    inFromRight.setInterpolator(new AccelerateDecelerateInterpolator());
    return inFromRight;
}

From source file:Main.java

public static TranslateAnimation getTranslateAnimationToSelf(float pivotFromX, float pivotToX, float pivotFromY,
        float pivotToY, int intDuration, boolean boolFillAfter) {
    TranslateAnimation mAnmation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, pivotFromX,
            Animation.RELATIVE_TO_SELF, pivotToX, Animation.RELATIVE_TO_SELF, pivotFromY,
            Animation.RELATIVE_TO_SELF, pivotToY);
    mAnmation.setDuration(intDuration);/* ww w  .ja  v  a 2 s .c o  m*/
    mAnmation.setFillAfter(boolFillAfter);
    // mAnmation.setRepeatMode(Animation.RESTART);
    // mAnmation.setRepeatCount(intRepeatCount);
    // mAnmation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
    // com.webclient.R.anim.bounce_interpolator));
    return mAnmation;
}

From source file:Main.java

public static TranslateAnimation getTranslateAnimationToParent(float pivotFromX, float pivotToX,
        float pivotFromY, float pivotToY, int intDuration, boolean boolFillAfter) {
    TranslateAnimation mAnmation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, pivotFromX,
            Animation.RELATIVE_TO_PARENT, pivotToX, Animation.RELATIVE_TO_PARENT, pivotFromY,
            Animation.RELATIVE_TO_PARENT, pivotToY);
    mAnmation.setDuration(intDuration);/*  w ww . j a  v  a  2  s .co m*/
    mAnmation.setFillAfter(boolFillAfter);
    // mAnmation.setRepeatMode(Animation.RESTART);
    // mAnmation.setRepeatCount(intRepeatCount);
    // mAnmation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
    // com.webclient.R.anim.bounce_interpolator));
    return mAnmation;
}

From source file:Main.java

public static void SlideInRight(View v, final Runnable onComplete) {
    v.clearAnimation();//from  w  w w.j a v a2s. com
    TranslateAnimation aout = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f);
    aout.setDuration(300);
    v.startAnimation(aout);
    if (onComplete != null)
        aout.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation arg0) {
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                onComplete.run();
            }
        });
}

From source file:Main.java

public static void SlideOutLeft(View v, final Runnable onComplete) {
    v.clearAnimation();//from  w  ww  .  j a  v a 2 s .  c  om
    TranslateAnimation aout = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF,
            -1f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f);
    aout.setDuration(300);
    aout.setFillAfter(true);
    v.startAnimation(aout);
    if (onComplete != null)
        aout.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation arg0) {
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                onComplete.run();
            }
        });
}

From source file:Main.java

public static void animationTranslate(View paramView) {
    animation(paramView, new TranslateAnimation(2, 0.0F, 2, 0.0F, 2, 1.0F, 2, 0.0F), 500L, 0L);
}

From source file:Main.java

public static void setTranslateAnimationToSelf(View view, float pivotFromX, float pivotToX, float pivotFromY,
        float pivotToY, int intDuration, boolean boolFillAfter) {
    TranslateAnimation mAnmation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, pivotFromX,
            Animation.RELATIVE_TO_SELF, pivotToX, Animation.RELATIVE_TO_SELF, pivotFromY,
            Animation.RELATIVE_TO_SELF, pivotToY);
    mAnmation.setDuration(intDuration);/*from w w  w. j a v a 2s .  co m*/
    mAnmation.setFillAfter(boolFillAfter);
    // mAnmation.setRepeatMode(Animation.RESTART);
    // mAnmation.setRepeatCount(intRepeatCount);
    // mAnmation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
    // com.webclient.R.anim.bounce_interpolator));
    view.startAnimation(mAnmation);
}