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

public static void expand(final View v) {
    v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;/*  w  w w .  j  a va2  s. c o m*/
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ? ViewGroup.LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

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

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

From source file:Main.java

public static void animExpand(final View v) {
    v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;//from   w  w w.  j  a  v  a 2  s  .  c o  m
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

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

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

From source file:Main.java

public static void animateScaleIn(View view, long duration, Animator.AnimatorListener listener) {
    view.setScaleX(0f);//w  ww. j ava 2s.c om
    view.setScaleY(0f);
    view.setVisibility(View.VISIBLE);

    AnimatorSet scaleSet = new AnimatorSet();
    scaleSet.playTogether(ObjectAnimator.ofFloat(view, View.SCALE_X, 1f),
            ObjectAnimator.ofFloat(view, View.SCALE_Y, 1f));
    scaleSet.setInterpolator(new AccelerateDecelerateInterpolator());
    scaleSet.setDuration(duration);
    if (listener != null) {
        scaleSet.addListener(listener);
    }
    scaleSet.start();
    //return scaleSet;
}

From source file:Main.java

/**
 * Optimize the method "setVisibility(View.Gone)"
 *
 * @param view//from w w w . j a v a  2 s. c om
 * @param gone
 * @param <V>
 * @return
 */
public static <V extends View> V setGone(V view, boolean gone) {
    if (view != null) {
        if (gone)
            if (View.GONE != view.getVisibility()) {
                view.setVisibility(View.GONE);
            }
    } else if (View.VISIBLE != view.getVisibility()) {
        view.setVisibility(View.VISIBLE);
    }
    return view;
}

From source file:Main.java

public static void show(View v) {
    if (v != null)
        v.setVisibility(View.VISIBLE);
}

From source file:Main.java

public static void showViewFromBottom(View view) {
    if (view.getVisibility() == View.VISIBLE) {
        return;/*from   w  w w  .  j  ava2s.  c o m*/
    }
    view.setVisibility(View.VISIBLE);
    int height = view.getHeight();
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0,
            Animation.ABSOLUTE, height, Animation.ABSOLUTE, 0);
    translateAnimation.setDuration(ANIMATION_DURATION);
    translateAnimation.setInterpolator(sAnimationInterpolator);
    view.startAnimation(translateAnimation);
}

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;//from w  w  w .  j  a va  2s  .  c om
    }
    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 showMessage(ViewGroup emptyView, String msg) {
    if (emptyView == null) {
        return;// w w  w  . jav a  2s  . c o m
    }
    ProgressBar pbLoading = (ProgressBar) emptyView.getChildAt(0);
    pbLoading.setVisibility(View.GONE);
    TextView tvEmptyMsg = (TextView) emptyView.getChildAt(1);
    tvEmptyMsg.setVisibility(View.VISIBLE);
    tvEmptyMsg.setText(msg);
}

From source file:Main.java

public static void expand(final View v) {
    v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    final int targtetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;/*w  ww  .j  a va 2s  .  co m*/
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT
                    : (int) (targtetHeight * interpolatedTime);
            v.requestLayout();
        }

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

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

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;/*  w  ww.  j a va  2 s.  c om*/
    }
    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);
}