Example usage for android.view View getVisibility

List of usage examples for android.view View getVisibility

Introduction

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

Prototype

@ViewDebug.ExportedProperty(mapping = { @ViewDebug.IntToString(from = VISIBLE, to = "VISIBLE"),
        @ViewDebug.IntToString(from = INVISIBLE, to = "INVISIBLE"),
        @ViewDebug.IntToString(from = GONE, to = "GONE") })
@Visibility
public int getVisibility() 

Source Link

Document

Returns the visibility status for this view.

Usage

From source file:Main.java

public static void showView(View view) {
    if (view != null) {
        if (view.getVisibility() != View.VISIBLE) {
            view.setVisibility(View.VISIBLE);
        }//  w  w w . j  a v a 2  s  .  c  o m
    }
}

From source file:Main.java

public static boolean isShow(View view) {
    if (view != null) {
        return view.getVisibility() == View.VISIBLE;
    } else {//  ww w.j a  va 2 s  .c om
        return false;
    }
}

From source file:Main.java

public static void setGone(View... views) {
    if (views != null && views.length > 0) {
        for (View view : views) {
            if (null != view && view.getVisibility() != View.GONE)
                view.setVisibility(View.GONE);
        }/*from ww  w.  jav a 2s.co m*/
    }
}

From source file:Main.java

public static void setVisible(View... views) {
    if (views != null && views.length > 0) {
        for (View view : views) {
            if (null != view && view.getVisibility() != View.VISIBLE)
                view.setVisibility(View.VISIBLE);
        }/*www.j  a v a 2  s .c om*/
    }
}

From source file:Main.java

public static void toggleContentVisibility(View... views) {
    for (final View v : views) {
        if (v.getVisibility() == View.GONE) {
            v.setAlpha(0);/*from  ww  w.j av a2s  . c  om*/
            v.setVisibility(View.VISIBLE);
            v.animate().alpha(1).start();
        } else {
            v.animate().alpha(0).setDuration(100).withEndAction(new Runnable() {
                @Override
                public void run() {
                    v.setVisibility(View.GONE);
                }
            }).start();
        }
    }
}

From source file:Main.java

/**
 * Fade in a view with the default time//from w ww.  j  av a 2 s .c o  m
 * @param view The {@link View} to use
 */
public static void fadeOut(View view) {
    if (view.getVisibility() != View.VISIBLE)
        return;

    // Since the button is still clickable before fade-out animation
    // ends, we disable the button first to block click.
    view.setEnabled(false);
    Animation animation = new AlphaAnimation(1F, 0F);
    animation.setDuration(400);
    view.startAnimation(animation);
    view.setVisibility(View.GONE);
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public static ViewPropertyAnimator fadeIn(View to, int duration) {
    if (to.getVisibility() != View.VISIBLE) {
        to.setAlpha(0f);//from  ww  w . j ava 2  s  .  c om
        to.setVisibility(View.VISIBLE);
    }
    to.clearAnimation();
    final ViewPropertyAnimator animator = to.animate();
    animator.alpha(1f).setDuration(duration).setListener(null);
    return animator;
}

From source file:Main.java

public static void animShow(View v, int duration, float from, float to) {
    if (v.getVisibility() == View.GONE) {
        v.setVisibility(View.VISIBLE);
    }/* w w  w.j  a v a  2s.  co m*/
    v.clearAnimation();
    ObjectAnimator.ofFloat(v, "alpha", from, to).setDuration(duration).start();

}

From source file:Main.java

public static void fadeViewOut(final View view, final int duration) {
    if (view.getVisibility() == View.GONE)
        return;/*from   w  ww . j a v  a2  s . c o m*/
    if (Build.VERSION.SDK_INT >= 12) {
        view.animate().setDuration(duration).alpha(0f).setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                view.setVisibility(View.GONE);
            }
        });
    } else {
        view.setVisibility(View.GONE);
    }
}

From source file:Main.java

public static void fadeIn(Context context, View view, boolean animate) {
    if (view == null || view.getVisibility() == View.VISIBLE) {
        return;/*from  ww w  .  ja v a 2  s.c o  m*/
    }
    if (animate) {
        view.startAnimation(
                android.view.animation.AnimationUtils.loadAnimation(context, android.R.anim.fade_in));
    } else {
        view.clearAnimation();
    }
    view.setVisibility(View.VISIBLE);
}