Example usage for android.view View VISIBLE

List of usage examples for android.view View VISIBLE

Introduction

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

Prototype

int VISIBLE

To view the source code for android.view View VISIBLE.

Click Source Link

Document

This view is visible.

Usage

From source file:Main.java

/**
 * Fade in a view with the default time/*from  w w w .  ja v a  2 s .  c  om*/
 * @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)
private static void fadeInHoneyComb(final View view) {
    view.setAlpha(0.0F);//  w ww.  j a v  a 2  s .  c  o  m
    view.setVisibility(View.VISIBLE);
    ObjectAnimator.ofFloat(view, "alpha", 0.0F, 1.0F).setDuration(ANIMATION_DURATION).start();
}

From source file:Main.java

@SuppressLint("NewApi")
public static void revealView(View toBeRevealed, View frame) {
    try {/*from w  w w . j a va  2  s  .co m*/
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            // get the center for the clipping circle
            int cx = (frame.getLeft() + frame.getRight()) / 2;
            int cy = (frame.getTop() + frame.getBottom()) / 2;

            // get the final radius for the clipping circle
            int finalRadius = Math.max(frame.getWidth(), frame.getHeight());
            Log.v("INFO", "Radius: " + finalRadius);

            // create the animator for this view (the start radius is zero)
            Animator anim = ViewAnimationUtils.createCircularReveal(toBeRevealed, cx, cy, 0, finalRadius);

            // make the view visible and start the animation
            toBeRevealed.setVisibility(View.VISIBLE);
            anim.start();
        } else {
            toBeRevealed.setVisibility(View.VISIBLE);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static ImageButton makeImageButton(Context context, int id, int resId, int width, int height,
        OnClickListener onClickListener, OnTouchListener onTouchListener) {
    Drawable icon;/*from  w ww  .  j  a  va2s.  c  om*/
    ImageButton button = new ImageButton(context);
    button.setId(id);
    if (onClickListener != null)
        button.setOnClickListener(onClickListener);
    button.setBackgroundColor(Color.TRANSPARENT);
    icon = context.getResources().getDrawable(resId);
    icon.setBounds(0, 0, width, height);

    Bitmap iconBitmap = ((BitmapDrawable) icon).getBitmap();
    Bitmap bitmapResized = Bitmap.createScaledBitmap(iconBitmap, width, height, false);
    button.setImageBitmap(bitmapResized);
    button.setVisibility(View.VISIBLE);
    if (onTouchListener != null)
        button.setOnTouchListener(onTouchListener);
    return button;
}

From source file:Main.java

public static void showViewAlphaAnim(final View view, TimeInterpolator interpolator, final boolean visible) {
    if (visible && view.getVisibility() == View.VISIBLE || !visible && view.getVisibility() != View.VISIBLE) {
        return;//  www .  j a  v  a 2 s.c o  m
    }

    float fromAlpha = visible ? 0.0F : 1.0F;
    float toAlpha = visible ? 1.0F : 0.0F;
    view.setAlpha(fromAlpha);
    view.setVisibility(View.VISIBLE);
    view.animate().alpha(toAlpha).setDuration(DURATION).setInterpolator(interpolator)
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    if (visible) {
                        view.setAlpha(1.0F);
                        view.setVisibility(View.VISIBLE);
                    } else {
                        view.setAlpha(0.0F);
                        view.setVisibility(View.INVISIBLE);
                    }
                }
            }).start();
}

From source file:Main.java

public static void setVisible(@NonNull View view, boolean visible, int invisibleFlag) {
    int visibility = view.getVisibility();
    int visibilityNew = visible ? View.VISIBLE : invisibleFlag;

    if (visibility != visibilityNew) {
        view.setVisibility(visibilityNew);
    }/*  w w w .  ja  v  a 2 s .  c  o  m*/
}

From source file:Main.java

public static void expandOrCollapse(final View v, boolean expand) {
    TranslateAnimation anim;//  w  w w  .  j a  va 2 s .c  o m
    if (expand) {
        anim = new TranslateAnimation(0.0f, 0.0f, -v.getHeight(), 0.0f);
        v.setVisibility(View.VISIBLE);
    } else {
        anim = new TranslateAnimation(0.0f, 0.0f, 0.0f, -v.getHeight());
        Animation.AnimationListener collapselistener = new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                // Useless
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                // Useless
            }

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

        anim.setAnimationListener(collapselistener);
    }

    anim.setDuration(300);
    anim.setInterpolator(new AccelerateInterpolator(0.5f));
    v.startAnimation(anim);
}

From source file:Main.java

public static void startFadeInAnimationOn(final View container, boolean forceFade) {
    if (forceFade || container.getVisibility() != View.VISIBLE) {
        Animation animation = getFadeInAnimation(FADE_DURATION);
        animation.setAnimationListener(new AnimationListener() {
            @Override/*from   ww w .  j av  a  2s  .co  m*/
            public void onAnimationStart(Animation animation) {
                container.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

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

        container.startAnimation(animation);
    }
}

From source file:Main.java

public static void startFadeOutAnimationOn(final View container, boolean forceFade) {
    if (forceFade || container.getVisibility() == View.VISIBLE) {
        Animation animation = getFadeOutAnimation(FADE_DURATION);
        animation.setAnimationListener(new AnimationListener() {
            @Override/*w  w w. j av  a 2  s  . c om*/
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

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

        container.startAnimation(animation);
    }
}

From source file:Main.java

public static void startCollapseViewAnimationOn(final View expandableContainer) {
    if (expandableContainer.getVisibility() == View.VISIBLE) {
        Animation animation = getCollapseViewAnimation(expandableContainer, EXPAND_OR_COLLAPSE_DURATION);
        expandableContainer.startAnimation(animation);
    }/* w ww. j a va  2 s.c o  m*/
}