Example usage for android.view.animation TranslateAnimation setFillAfter

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

Introduction

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

Prototype

public void setFillAfter(boolean fillAfter) 

Source Link

Document

If fillAfter is true, the transformation that this animation performed will persist when it is finished.

Usage

From source file:Main.java

public static TranslateAnimation getTranslation(int fromX, int toX, int fromY, int toY, int duration,
        Animation.AnimationListener listener) {

    TranslateAnimation anim = new TranslateAnimation(fromX, toX, fromY, toY);
    anim.setDuration(duration);/*from  w ww.j  a  va2  s. co  m*/
    anim.setFillAfter(true);

    anim.setAnimationListener(listener);
    return anim;
}

From source file:Main.java

/**
 *    move the background view(translate animation).
 * //from  w  w  w.  j  a v a2 s  .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 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);
    return translate;
}

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);//from   w  w w .ja v a  2s  . co  m
    shake_1.setStartOffset(0);
    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

/**
 *    move the background view(translate animation).
 * /*from  w w w  . jav a 2 s  . co  m*/
 * @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);
}

From source file:Main.java

public static void SlideOutLeft(View v, final Runnable onComplete) {
    v.clearAnimation();/*from www.  j a  v a  2s .co m*/
    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

/**
 * 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  w  ww  .java 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 void translateY(final View view, float fromY, float toY, long duration) {
    if (Build.VERSION.SDK_INT >= 12) {
        if (duration == 0)
            view.setTranslationY(toY);// w  w  w . ja  v a 2s  .  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

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);/*from   ww  w  .  ja  v  a 2  s  . c  om*/
    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 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 ww .  j av  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);
}