Example usage for android.view.animation Animation setFillAfter

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

Introduction

In this page you can find the example usage for android.view.animation Animation 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

/**
 *
 * @param view/*w w w . j a  v a 2s  . c om*/
 * @param duration
 */
public static void fadeOut(final View view, long duration) {
    Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(duration);

    animation.setFillAfter(true);
    animation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            Message message = Message.obtain();
            message.obj = view;
            handler.sendMessage(message);
        }
    });

    view.startAnimation(animation);
}

From source file:Main.java

public static Animation getScaleAnimation(float fromX, float toX, float fromY, float toY, long duration) {
    Animation alpha = new ScaleAnimation(fromX, toX, fromY, toY, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    alpha.setDuration(duration);/*from w w  w.  ja va  2 s  .c  om*/
    alpha.setFillAfter(true);
    return alpha;
}

From source file:Main.java

public static Animation getSmallerAnimation(int duration) {
    Animation animation = new ScaleAnimation(1.0f, 0f, 1.0f, 0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(duration);//from   w  ww .  jav a  2 s  .  c  o m
    animation.setFillAfter(true);
    return animation;
}

From source file:Main.java

public static void startScaleAnimationOn(View view, float startScale, float endScale, long duration) {
    Animation anim = new ScaleAnimation(1f, 1f, startScale, endScale, Animation.ABSOLUTE, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    anim.setDuration(duration);/*from   w  w  w  . j a v a2  s  .co m*/
    anim.setFillAfter(true);
    view.startAnimation(anim);
}

From source file:Main.java

public static void slideToUp(View view) {
    Animation slide = 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);

    slide.setDuration(400);/*from  w  w w .  jav a2s.  c o  m*/
    slide.setFillAfter(true);
    slide.setFillEnabled(true);
    view.startAnimation(slide);

    slide.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

}

From source file:Main.java

/**
 * Applies a fade in animation and set the visibility in
 * {@link View#VISIBLE}./*from   w ww  . j  a va2s  .  co  m*/
 * @param view view to animate.
 */
public static void fadeInView(final View view) {
    if (view.getVisibility() != View.VISIBLE) {
        cancelAnimation(view);
        view.setVisibility(View.VISIBLE);
        Animation animation = android.view.animation.AnimationUtils.loadAnimation(view.getContext(),
                android.R.anim.fade_in);
        animation.setFillEnabled(true);
        animation.setFillBefore(true);
        animation.setFillAfter(true);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                view.clearAnimation();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        view.setAnimation(animation);
        animation.start();
    }
}

From source file:Main.java

/**
 * Applies a fade out animation and set the visibility in
 * {@link View#GONE}.//from  www.  ja  v  a  2  s .  c o  m
 * @param view view to animate.
 */
public static void fadeOutView(final View view) {
    if (view.getVisibility() == View.VISIBLE) {
        cancelAnimation(view);
        Animation animation = android.view.animation.AnimationUtils.loadAnimation(view.getContext(),
                android.R.anim.fade_out);
        animation.setFillEnabled(true);
        animation.setFillBefore(true);
        animation.setFillAfter(true);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                view.setVisibility(View.GONE);
                view.clearAnimation();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        view.setAnimation(animation);
        animation.start();
    }
}

From source file:com.capricorn.ArcMenu.java

private static Animation createQuickHintSwitchAnimation(final boolean expanded) {
    Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setStartOffset(0);//from  w w w  .  j a v a 2 s .  co  m
    animation.setDuration(10);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setFillAfter(true);

    return animation;
}

From source file:com.capricorn.ArcMenu.java

private static Animation createHintSwitchAnimation(final boolean expanded) {
    Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setStartOffset(0);/*from   w  w  w.j a  v a  2  s . c  om*/
    animation.setDuration(100);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setFillAfter(true);

    return animation;
}

From source file:Main.java

public static Animation getTranslationAnimation(boolean fromTheCenter, boolean toTheRight, int distance,
        int time) {
    Animation animation = null;
    if (fromTheCenter && toTheRight) {
        animation = new TranslateAnimation(0, distance, 0, 0);
    } else if (fromTheCenter && !toTheRight) {
        animation = new TranslateAnimation(0, -distance, 0, 0);
    } else if (!fromTheCenter && toTheRight) {
        animation = new TranslateAnimation(distance, 0, 0, 0);
    } else if (!fromTheCenter && !toTheRight) {
        animation = new TranslateAnimation(-distance, 0, 0, 0);
    }/*from  w  ww.ja va  2 s  . c o m*/
    animation.setDuration(time);
    animation.setFillAfter(true);
    return animation;
}