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

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public static void showProgress(Activity activity, final View defaultView, final View progressView,
        final boolean show) {

    // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
    // for very easy animations. If available, use these APIs to fade-in
    // the progress spinner.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        int shortAnimTime = activity.getResources().getInteger(android.R.integer.config_shortAnimTime);

        defaultView.setVisibility(show ? View.GONE : View.VISIBLE);
        defaultView.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
                .setListener(new AnimatorListenerAdapter() {
                    @Override//from w  ww  . jav a  2s.c  om
                    public void onAnimationEnd(Animator animation) {
                        defaultView.setVisibility(show ? View.GONE : View.VISIBLE);
                    }
                });

        progressView.setVisibility(show ? View.VISIBLE : View.GONE);
        progressView.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        progressView.setVisibility(show ? View.VISIBLE : View.GONE);
                    }
                });

    } else {
        // The ViewPropertyAnimator APIs are not available, so simply show
        // and hide the relevant UI components.
        progressView.setVisibility(show ? View.VISIBLE : View.GONE);
        defaultView.setVisibility(show ? View.GONE : View.VISIBLE);
    }
}

From source file:Main.java

public static ObjectAnimator to_alpha(View target) {

    ObjectAnimator objectAnimator = null;
    if (null != target && target.getVisibility() != View.VISIBLE) {
        target.setVisibility(View.VISIBLE);

        objectAnimator = ObjectAnimator.ofFloat(target, View.ALPHA, 0f, 1f)
                .setDuration(BUBBLE_ANIMATION_DURATION);

        objectAnimator.start();/*from  ww  w .j  a va2  s  .c o m*/
    }

    return objectAnimator;
}

From source file:Main.java

public static ObjectAnimator inflateFadeIn(final View v) {
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0f, 1f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0f, 1f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f, 1f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(v, scaleX, scaleY, alpha);
    animator.setDuration(ANIM_DURATION_INFLATE);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override//  w  w w  .ja va  2  s . c o m
        public void onAnimationStart(Animator animation) {
            v.setVisibility(View.VISIBLE);
        }
    });

    return animator;
}

From source file:Main.java

public static void fadeOut(final View view, AnimationListener animationListener, int duration) {
    view.setVisibility(View.VISIBLE);
    Animation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
    alphaAnimation.setDuration(duration);
    alphaAnimation.setAnimationListener(animationListener);
    view.startAnimation(alphaAnimation);
}

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 w w. j a  va  2  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 crossFade(final View toBeGone, View toBeVisible, int shortAnimationDuration) {
    if (Build.VERSION.SDK_INT >= 12) {
        toBeVisible.setAlpha(0f);// w w w.  j  a  v a  2  s. c o  m
        toBeVisible.setVisibility(View.VISIBLE);
        toBeVisible.animate().alpha(1f).setDuration(shortAnimationDuration).setListener(null);

        toBeGone.animate().alpha(0f).setDuration(shortAnimationDuration)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        toBeGone.setVisibility(View.GONE);
                    }
                });

    } else {
        switchOutIn(toBeGone, toBeVisible);
    }
}

From source file:Main.java

@SuppressLint("NewApi")
public static void revealView(View toBeRevealed, View frame) {
    try {//from  w ww  .ja  v a  2  s  .c o  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());

            // 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

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public static ViewPropertyAnimator fadeOut(final View from, int duration) {
    if (from.getVisibility() == View.VISIBLE) {
        from.clearAnimation();/* w  w w . j  av a2 s. c om*/
        final ViewPropertyAnimator animator = from.animate();
        animator.alpha(0f).setDuration(duration).setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                from.setVisibility(View.INVISIBLE);
                from.setAlpha(1f);
            }
        });
        return animator;
    }
    return null;
}

From source file:Main.java

public static Animation slideIn(View view, int from) {
    view.setVisibility(View.VISIBLE);
    Animation anim;/*from  www.  j  av a2  s.  c om*/
    switch (from) {
    case DIRECTION_LEFT:
        anim = new TranslateAnimation(-view.getWidth(), 0, 0, 0);
        break;
    case DIRECTION_RIGHT:
        anim = new TranslateAnimation(view.getWidth(), 0, 0, 0);
        break;
    case DIRECTION_UP:
        anim = new TranslateAnimation(0, 0, -view.getHeight(), 0);
        break;
    case DIRECTION_DOWN:
        anim = new TranslateAnimation(0, 0, view.getHeight(), 0);
        break;
    default:
        throw new IllegalArgumentException(Integer.toString(from));
    }
    anim.setDuration(500);
    view.startAnimation(anim);
    return anim;
}

From source file:Main.java

private static void fadeInPreHoneyComb(final View view) {
    AlphaAnimation alphaAnimation = new AlphaAnimation(0.0F, 1.0F);
    alphaAnimation.setDuration(ANIMATION_DURATION);
    view.setVisibility(View.VISIBLE);
    view.startAnimation(alphaAnimation);
}