Example usage for android.view View getMeasuredHeight

List of usage examples for android.view View getMeasuredHeight

Introduction

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

Prototype

public final int getMeasuredHeight() 

Source Link

Document

Like #getMeasuredHeightAndState() , but only returns the raw height component (that is the result is masked by #MEASURED_SIZE_MASK ).

Usage

From source file:Main.java

private static int getInitialHeight(View v) {
    int initialHeight = v.getMeasuredHeight();
    return initialHeight;
}

From source file:Main.java

public static int getViewHeight(View context) {
    return context.getMeasuredHeight();
}

From source file:Main.java

public static void slideInDown(View v) {
    v.setTranslationY(-v.getMeasuredHeight());
    v.setVisibility(View.VISIBLE);
    v.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setDuration(ANIMATION_DURATION)
            .translationY(0).start();//from  www.j  av a 2 s . c  o m
}

From source file:Main.java

public static int getViewMeasuredHeight(View view) {
    calcViewMeasure(view);
    return view.getMeasuredHeight();
}

From source file:Main.java

public static int getViewHeight(View view) {
    if (view != null) {
        int height = view.getMeasuredHeight();
        if (height == 0) {
            LayoutParams params = view.getLayoutParams();
            if (params != null && params.height > 0) {
                return params.height;
            }/*from  w w w.j a  v a  2s.  c  om*/
            view.measure(0, 0);
            height = view.getMeasuredHeight();
        }
        return height;
    }
    return 0;
}

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  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(ANIM);
    v.startAnimation(a);
}

From source file:Main.java

public static int getViewHeight(View view) {
    measureView(view);
    return view.getMeasuredHeight();
}

From source file:Main.java

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

    Animation a = new Animation() {
        @Override/* w  ww  .j ava 2  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) * 2);
    v.startAnimation(a);
}

From source file:Main.java

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

    return new Animation() {
        @Override// w ww  .j  a  v a2  s.c  o m
        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 collapseViews(final View v) {
    final int initialHeight = v.getMeasuredHeight();

    Animation a = new Animation() {
        @Override/*w  w  w  .  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((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density) * 1);
    v.startAnimation(a);
}