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

private static Animation collapseAnimation(final View drawer) {
    final int initialHeight = drawer.getMeasuredHeight();

    return new Animation() {
        @Override//from   w ww  . ja v a 2 s.  com
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                drawer.setVisibility(View.GONE);
            } else {
                drawer.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                drawer.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };
}

From source file:Main.java

public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override/* w  w w . j av a  2 s . com*/
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density) * 2);
    v.startAnimation(a);
}

From source file:Main.java

public static ObjectAnimator fadeIn(final View v) {
    ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(v, "alpha", 0f, 1f);
    alphaAnim.setDuration(ANIM_DURATION_FADEIN);
    alphaAnim.addListener(new AnimatorListenerAdapter() {
        @Override/*from   www. ja  va 2s  .c om*/
        public void onAnimationStart(Animator animation) {
            v.setVisibility(View.VISIBLE);
        }
    });

    return alphaAnim;
}

From source file:Main.java

public static void collapseViews(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override//from   w  ww  .  ja v  a2 s .c o  m
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density) * 1);
    v.startAnimation(a);
}

From source file:Main.java

public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override//from   www. j a v  a2 s  .com
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}

From source file:Main.java

public static void animCollapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override/*from w ww  .ja va2 s.  c o  m*/
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}

From source file:Main.java

public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override/*from   w ww.j av  a2  s .  co m*/
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration(1000);
    // a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}

From source file:Main.java

public static void showEmpty(Activity activity, boolean show, View emptyView) {
    Animation anim = AnimationUtils.loadAnimation(activity,
            show ? android.R.anim.fade_in : android.R.anim.fade_out);
    if (show && (emptyView.getVisibility() == View.GONE || emptyView.getVisibility() == View.INVISIBLE)) {
        emptyView.setAnimation(anim);/*  w  w  w . j av  a  2  s  .  co  m*/
        emptyView.setVisibility(View.VISIBLE);
    } else if (!show && emptyView.getVisibility() == View.VISIBLE) {
        emptyView.setAnimation(anim);
        emptyView.setVisibility(View.GONE);
    }
}

From source file:Main.java

public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();
    Animation a = new Animation() {
        @Override/*  ww w  .ja v  a  2  s.co  m*/
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1) {
                v.setVisibility(View.GONE);
            } else {
                v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
                v.requestLayout();
            }
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    a.setDuration(300);
    v.startAnimation(a);
}

From source file:Main.java

public static void animateBounceIn(final View target) {
    AnimatorSet set = new AnimatorSet();
    set.playTogether(ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1, 1),
            ObjectAnimator.ofFloat(target, "scaleX", 0.3f, 1.05f, 0.9f, 1),
            ObjectAnimator.ofFloat(target, "scaleY", 0.3f, 1.05f, 0.9f, 1));
    set.setDuration(500);//from  w ww .j av  a  2  s.c o  m
    target.setVisibility(View.VISIBLE);
    set.start();
}