Example usage for android.view View setVisibility

List of usage examples for android.view View setVisibility

Introduction

In this page you can find the example usage for android.view View setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:Main.java

public static void fadeOut(final View view, int millis) {
    view.animate().alpha(0f).setDuration(millis).setListener(null);
    new Handler().postDelayed(new Runnable() {
        public void run() {
            view.setVisibility(View.GONE);
        }/*from  www.  j  ava2s.  co  m*/
    }, millis);
}

From source file:Main.java

private static AnimationListener getFadeOutListener(final View view) {
    final AnimationListener fadeOutListener = new AnimationListener() {

        public void onAnimationEnd(final Animation animation) {
            view.setVisibility(View.INVISIBLE);
        }/*from ww  w .ja  v a2s.  c  o  m*/

        public void onAnimationRepeat(final Animation animation) {

        }

        public void onAnimationStart(final Animation animation) {

        }
    };

    return fadeOutListener;
}

From source file:Main.java

public static void scaleShow(final View view, final Runnable rWhenEnd) {
    if (view.getVisibility() == View.VISIBLE) {
        view.setVisibility(View.VISIBLE);
        if (rWhenEnd != null) {
            rWhenEnd.run();/*from w ww  . j  a  va 2  s.  c  o  m*/
        }
        return;
    }
    if (view.getWindowToken() == null) {
        view.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
            @Override
            public void onViewAttachedToWindow(View v) {
                scaleShow(view);
            }

            @Override
            public void onViewDetachedFromWindow(View v) {

            }
        });
    }
    ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0f, 1f);
    ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0f, 1f);
    AnimatorSet set = new AnimatorSet();
    set.playTogether(scaleX, scaleY);
    set.setDuration(DURATION_SHORT);
    set.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.VISIBLE);
            if (rWhenEnd != null) {
                rWhenEnd.run();
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            view.setVisibility(View.VISIBLE);
            if (rWhenEnd != null) {
                rWhenEnd.run();
            }
        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    set.start();
}

From source file:Main.java

public static void setVisibility(final View v, long delay, final int visibility) {
    if (v != null && delay >= 0) {
        v.postDelayed(new Runnable() {
            @Override//from   w ww .  j a  va 2 s  .  c om
            public void run() {
                v.setVisibility(visibility);
            }
        }, delay);
    }
}

From source file:Main.java

public static void postAnimation(final View childLayout, int delay, final int duration) {
    int visibility = childLayout.getVisibility();
    if (visibility != View.VISIBLE) {
        return;// w  w w  .  j ava 2  s.  c  o m
    }
    childLayout.setVisibility(View.INVISIBLE);
    childLayout.postDelayed(new Runnable() {
        @Override
        public void run() {
            childLayout.setVisibility(View.VISIBLE);
            AnimationSet animationSet = new AnimationSet(true);
            animationSet.setDuration(duration);
            animationSet.setInterpolator(new OvershootInterpolator(0.8f));
            int pivotXType = Animation.RELATIVE_TO_SELF;
            animationSet.addAnimation(
                    new TranslateAnimation(pivotXType, -1, pivotXType, 0, pivotXType, 0, pivotXType, 0));
            animationSet.addAnimation(new AlphaAnimation(0, 1));
            childLayout.startAnimation(animationSet);
        }
    }, delay);
}

From source file:Main.java

public static void animSlideOutFromTop(final View view) {
    TranslateAnimation animate = new TranslateAnimation(0, 0, 0, view.getHeight());
    animate.setDuration(400);/*  w  w  w .  ja  v  a 2s.  c  om*/
    animate.setFillAfter(true);
    view.startAnimation(animate);
    view.setVisibility(View.GONE);
}

From source file:Main.java

public static void postAnimationBottom(final View childLayout, int delay, final int duration) {
    int visibility = childLayout.getVisibility();
    if (visibility != View.VISIBLE) {
        return;/*from w w w.j  a  v a2s . co  m*/
    }
    childLayout.setVisibility(View.INVISIBLE);
    childLayout.postDelayed(new Runnable() {
        @Override
        public void run() {
            childLayout.setVisibility(View.VISIBLE);
            AnimationSet animationSet = new AnimationSet(true);
            animationSet.setDuration(duration);
            animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
            int pivotXType = Animation.RELATIVE_TO_SELF;
            animationSet.addAnimation(
                    new TranslateAnimation(pivotXType, 0, pivotXType, 0, pivotXType, 1, pivotXType, 0));
            animationSet.addAnimation(new AlphaAnimation(0, 1));
            childLayout.startAnimation(animationSet);
        }
    }, delay);
}

From source file:Main.java

public static void fadeView(View view, boolean show, boolean animate) {

    // Cancel any on-going animation
    ViewCompat.animate(view).cancel();/*from w  ww. j  av  a2 s  .c  o m*/

    if (show) {
        view.setVisibility(View.VISIBLE);
        if (animate) {
            ViewCompat.setAlpha(view, 0f);
            ViewCompat.animate(view).alpha(1f).start();
        } else {
            ViewCompat.setAlpha(view, 1f);
        }
    } else {
        if (view.getVisibility() == View.VISIBLE) {
            if (animate) {
                ViewCompat.animate(view).alpha(0f).setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(View view) {
                        ViewCompat.animate(view).setListener(null);
                        view.setVisibility(View.INVISIBLE);
                    }
                }).start();
            } else {
                view.setVisibility(View.INVISIBLE);
            }
        }
    }

}

From source file:Main.java

public static void downOut(View fragmentView) {
    //        View fragmentView = getView();
    if (null != fragmentView && View.GONE != fragmentView.getVisibility()) {
        fragmentView.startAnimation(ANIM_DOWN_OUT);
        fragmentView.setVisibility(View.GONE);

        //            onPageLeave();
    }//from   www.  jav a  2 s . c om
}

From source file:Main.java

public static void animSlideOutFromBottom(final View view) {
    TranslateAnimation animate = new TranslateAnimation(0, 0, 0, -view.getHeight());
    animate.setDuration(500);//w  w  w .j a v  a2  s  .  com
    animate.setFillAfter(true);
    view.startAnimation(animate);
    view.setVisibility(View.GONE);
}