Example usage for android.view.animation AlphaAnimation setFillAfter

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

Introduction

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

private static void setAlpha(View view, float alphaValue) {

    if (alphaValue == 1) {
        view.clearAnimation();//from w ww .j  ava2 s  .co m
    } else {
        AlphaAnimation alpha = new AlphaAnimation(alphaValue, alphaValue);
        alpha.setDuration(0); // Make animation instant
        alpha.setFillAfter(true); // Tell it to persist after the animation ends       
        view.startAnimation(alpha);
    }

}

From source file:Main.java

public static AnimationSet RotateAndFadeInAnimation() {

    AlphaAnimation fade_in = new AlphaAnimation(0.2f, 1f);
    fade_in.setDuration(400);/*w  w w .j  ava 2 s . c o m*/
    fade_in.setStartOffset(0);
    fade_in.setFillAfter(true);

    ScaleAnimation expand = new ScaleAnimation(0.2f, 1, 0.2f, 1, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    expand.setDuration(500);
    expand.setStartOffset(0);
    expand.setFillAfter(true);

    RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    rotate.setDuration(500);
    rotate.setStartOffset(0);
    // rotate.setInterpolator(new LinearInterpolator());
    rotate.setFillAfter(true);

    AnimationSet Reload = new AnimationSet(true);
    Reload.addAnimation(fade_in);
    Reload.addAnimation(expand);
    Reload.addAnimation(rotate);
    Reload.setInterpolator(new DecelerateInterpolator(1.3f));
    return Reload;
}

From source file:Main.java

public static AnimationSet RotateAndFadeOutAnimation() {
    AlphaAnimation fade_out = new AlphaAnimation(1f, 0.2f);
    fade_out.setDuration(500);/*w w w  .j  a v a 2  s .  co m*/
    fade_out.setStartOffset(0);
    fade_out.setFillAfter(true);

    ScaleAnimation shrink = new ScaleAnimation(1f, 0.2f, 1f, 0.2f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    shrink.setDuration(400);
    shrink.setStartOffset(0);
    shrink.setFillAfter(true);

    RotateAnimation rotate = new RotateAnimation(0.0f, 360f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    rotate.setDuration(500);
    rotate.setStartOffset(0);
    rotate.setInterpolator(new LinearInterpolator());
    rotate.setFillAfter(true);

    AnimationSet Reload = new AnimationSet(true);
    Reload.addAnimation(fade_out);
    Reload.addAnimation(shrink);
    Reload.addAnimation(rotate);
    Reload.setInterpolator(new AccelerateInterpolator(1.1f));

    return Reload;
}

From source file:Main.java

public static AlphaAnimation fadeBackgroundAnimation() {
    AlphaAnimation alpha = new AlphaAnimation(0.5f, 0.2f);
    alpha.setRepeatCount(Animation.INFINITE);
    alpha.setRepeatMode(Animation.REVERSE);
    alpha.setDuration(1200);//from  ww w  .  j a  va2 s  .co m
    alpha.setFillAfter(true);
    return alpha;
}

From source file:org.wheelmap.android.utils.ViewTool.java

public static void setAlphaForView(View alphaView, float alpha) {

    AlphaAnimation animation = new AlphaAnimation(alpha, alpha);

    animation.setDuration(0);/*from  www.jav a 2  s  . c  o  m*/
    animation.setFillAfter(true);

    alphaView.startAnimation(animation);
}

From source file:com.dm.material.dashboard.candybar.utils.Animator.java

public static void startAlphaAnimation(@Nullable View view, long duration, int visibility) {
    if (view == null)
        return;/* w  w w .  ja v  a2 s.c  om*/

    AlphaAnimation alphaAnimation = (visibility == View.VISIBLE) ? new AlphaAnimation(0f, 1f)
            : new AlphaAnimation(1f, 0f);

    alphaAnimation.setDuration(duration);
    alphaAnimation.setFillAfter(true);
    view.startAnimation(alphaAnimation);
}

From source file:com.findme.views.ExpandableTextView.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static void applyAlphaAnimation(View view, float alpha) {
    if (isPostHoneycomb()) {
        view.setAlpha(alpha);/*from   w w  w. j a v a  2s . c om*/
    } else {
        AlphaAnimation alphaAnimation = new AlphaAnimation(alpha, alpha);
        // make it instant
        alphaAnimation.setDuration(0);
        alphaAnimation.setFillAfter(true);
        view.startAnimation(alphaAnimation);
    }
}

From source file:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * First part of the click animation.//from www .ja v  a 2 s  .com
 *
 * @param context Any context.
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimDown(Context context, View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = new View(context);
    rectView.setId(R.id.rect_view_id);
    rectView.setVisibility(View.GONE);
    rectView.setBackgroundResource(R.drawable.square);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(v.getMeasuredWidth(),
            v.getMeasuredHeight());
    params.addRule(RelativeLayout.ALIGN_TOP, v.getId());
    rectView.setLayoutParams(params);
    AlphaAnimation rectAnim = new AlphaAnimation(0f, 0.4f);
    rectAnim.setFillAfter(true);
    rectAnim.setInterpolator(new AccelerateInterpolator());
    rectAnim.setDuration(150);
    rectAnim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            rectView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    root.addView(rectView);
    rectView.startAnimation(rectAnim);
}

From source file:fr.shywim.antoinedaniel.utils.Utils.java

/**
 * Second part of the click animation.//from  www . ja v  a 2s . co  m
 *
 * @param v View who will have the effect.
 * @param isRoot Whether the passed view is the ViewGroup parent.
 */
public static void clickAnimUp(View v, boolean isRoot) {
    RelativeLayout root;
    if (isRoot)
        root = (RelativeLayout) v;
    else
        root = (RelativeLayout) v.getParent();
    final View rectView = root.findViewById(R.id.rect_view_id);
    if (rectView != null) {
        AlphaAnimation rectAnim = new AlphaAnimation(0.4f, 0f);
        rectAnim.setFillAfter(true);
        rectAnim.setInterpolator(new DecelerateInterpolator());
        rectAnim.setDuration(150);
        rectAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        ViewGroup parent = (ViewGroup) rectView.getParent();
                        rectView.setVisibility(View.GONE);
                        if (parent != null)
                            parent.removeView(rectView);
                    }
                });
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        rectView.clearAnimation();
        rectView.startAnimation(rectAnim);
    }
}

From source file:me.tylerbwong.pokebase.gui.activities.PokemonProfileActivity.java

public static void startAlphaAnimation(View view, long duration, int visibility) {
    AlphaAnimation alphaAnimation = (visibility == View.VISIBLE) ? new AlphaAnimation(0f, 1f)
            : new AlphaAnimation(1f, 0f);

    alphaAnimation.setDuration(duration);
    alphaAnimation.setFillAfter(true);
    view.startAnimation(alphaAnimation);
}