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:br.com.bioscada.apps.biotracks.fragments.ChooseActivityTypeDialogFragment.java

private static void updateWeightContainer(View weightContainer, int position) {
    boolean showWeight = position == 0 || position == 1 || position == 2;
    weightContainer.setVisibility(showWeight ? View.VISIBLE : View.GONE);
}

From source file:Main.java

@Deprecated
public static void initViewWHAndGone(final View view) {
    view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override//from w  ww  .ja va  2  s.c o m
        public void onGlobalLayout() {
            view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            view.setVisibility(View.GONE);
        }
    });

}

From source file:Main.java

/**
 * Scales in the view from scale of 0 to actual dimensions.
 * @param view The view to scale./*from  w w w .ja v  a 2 s.co  m*/
 * @param durationMs The duration of the scaling in milliseconds.
 * @param startDelayMs The delay to applying the scaling in milliseconds.
 */
public static void scaleIn(final View view, int durationMs, int startDelayMs) {
    AnimatorListenerAdapter listener = (new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            view.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            view.setScaleX(1);
            view.setScaleY(1);
        }
    });
    scaleInternal(view, 0 /* startScaleValue */, 1 /* endScaleValue */, durationMs, startDelayMs, listener,
            EASE_IN);
}

From source file:Main.java

public static void hidePanelAndKeyboard(View panelLayout) {
    final Activity activity = (Activity) panelLayout.getContext();
    final View focusView = activity.getCurrentFocus();
    if (focusView != null) {
        hideKeyboard(activity.getCurrentFocus());
        focusView.clearFocus();//from w w w . j a  v a 2  s .c o  m
    }
    panelLayout.setVisibility(View.GONE);
}

From source file:Main.java

public static void fadeToVisible(final View view, int startOffset, int duration) {
    int visibility = view.getVisibility();
    if (visibility != View.VISIBLE) {
        AlphaAnimation anim = new AlphaAnimation(0, 1);
        anim.setDuration(duration);/*from  w  w w  . j a  va 2 s .c  om*/
        anim.setStartOffset(startOffset);
        view.setVisibility(View.VISIBLE);
        view.startAnimation(anim);
    }
}

From source file:android.support.design.widget.BasicBehavior.java

public static void scaleShow(View view, ViewPropertyAnimatorListener viewPropertyAnimatorListener) {
    view.setVisibility(View.VISIBLE);
    ViewCompat.animate(view).scaleX(1.0f).scaleY(1.0f).alpha(1.0f).setDuration(800)
            .setInterpolator(FASTOUTSLOWININTERPOLATOR).setListener(viewPropertyAnimatorListener).start();
}

From source file:Main.java

public static void fadeToInvisible(final View view, int startOffset, int duration) {
    int visibility = view.getVisibility();
    if (visibility != View.INVISIBLE) {
        AlphaAnimation anim = new AlphaAnimation(1, 0);
        anim.setStartOffset(startOffset);
        anim.setDuration(duration);/*from w  w  w.  jav  a 2  s .  c o  m*/
        view.setVisibility(View.INVISIBLE);
        view.startAnimation(anim);
    }
}

From source file:com.microsoft.azure.engagement.ProductDiscountActivity.java

/**
 * Method that animates a view/*from  www .  j  a  v  a  2s .co m*/
 *
 * @param view           The view to animate
 * @param objectAnimator The objectAnimator to play
 * @param isVisible      The visibility of the view at the end of the animation
 */
public static final void performAnimation(final View view, ObjectAnimator objectAnimator,
        final boolean isVisible) {
    view.setVisibility(View.VISIBLE);

    objectAnimator.setDuration(300);

    final AnimatorSet animatorSet = new AnimatorSet();

    animatorSet.play(objectAnimator);

    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE);
        }
    });
    animatorSet.start();
}

From source file:Main.java

public static void bindView(ObjectAnimator animator, final View view) {

    animator.addListener(new Animator.AnimatorListener() {
        @Override//from   ww  w .jav a  2s  .  c o  m
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
}

From source file:Main.java

public static void collapse(final View v) {
    final int initialHeight = v.getMeasuredHeight();
    Animation a = new Animation() {
        @Override//from  ww w  .j  a  v  a2s  .  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(ANIM);
    v.startAnimation(a);
}