Java Code Examples for android.view.View#getMinimumHeight()

The following examples show how to use android.view.View#getMinimumHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MinHeightAttr.java    From AndroidAutoLayout with Apache License 2.0 6 votes vote down vote up
public static int getMinHeight(View view)
{
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        return view.getMinimumHeight();
    } else
    {
        try
        {
            Field minHeight = view.getClass().getField("mMinHeight");
            minHeight.setAccessible(true);
            return (int) minHeight.get(view);
        } catch (Exception e)
        {
        }
    }

    return 0;
}
 
Example 2
Source File: CommonUtils.java    From CommonUtils with Apache License 2.0 5 votes vote down vote up
public static void expand(final View v, @Nullable Animation.AnimationListener listener) {
    final int targetHeight;
    if (v.getMinimumHeight() != 0) {
        targetHeight = v.getMinimumHeight();
    } else {
        v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        targetHeight = v.getMeasuredHeight();
    }

    v.getLayoutParams().height = 0;
    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;
        }
    };

    if (listener != null) a.setAnimationListener(listener);

    a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
Example 3
Source File: ViewUtils.java    From AndroidScreenAdaptation with Apache License 2.0 5 votes vote down vote up
public static int getMinHeight(View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        return view.getMinimumHeight();
    } else {
        return getValue(view, METHOD_GET_MIN_HEIGHT);
    }
}
 
Example 4
Source File: WidgetUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * View Measure
 * @param view              待计算 View
 * @param widthMeasureSpec  horizontal space requirements as imposed by the parent
 * @param heightMeasureSpec vertical space requirements as imposed by the parent
 * @param maximumWidth      maximum Width
 * @param maximumHeight     maximum Height
 * @param defaultValue      默认值
 * @return measure space Array
 */
public static int[] viewMeasure(final View view, final int widthMeasureSpec, final int heightMeasureSpec,
                                final int maximumWidth, final int maximumHeight, final int defaultValue) {
    int minimumWidth = 0, minimumHeight = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        minimumWidth = view.getMinimumWidth();
        minimumHeight = view.getMinimumHeight();
    }
    return viewMeasure(widthMeasureSpec, heightMeasureSpec,
        minimumWidth, maximumWidth, minimumHeight, maximumHeight, defaultValue);
}
 
Example 5
Source File: ViewUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取 View 最小高度
 * @param view View
 * @return View 最小高度
 */
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
public static int getMinimumHeight(final View view) {
    if (view != null) {
        return view.getMinimumHeight();
    }
    return 0;
}
 
Example 6
Source File: ViewCompatJB.java    From letv with Apache License 2.0 4 votes vote down vote up
public static int getMinimumHeight(View view) {
    return view.getMinimumHeight();
}
 
Example 7
Source File: ViewCompatJB.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public static int getMinimumHeight(View view) {
    return view.getMinimumHeight();
}