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

The following examples show how to use android.view.View#getMeasuredState() . 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: BaselineLayout.java    From PagerBottomTabStrip with Apache License 2.0 5 votes vote down vote up
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int count = getChildCount();
    int maxWidth = 0;
    int maxHeight = 0;
    int maxChildBaseline = -1;
    int maxChildDescent = -1;
    int childState = 0;

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == GONE) {
            continue;
        }

        measureChild(child, widthMeasureSpec, heightMeasureSpec);
        final int baseline = child.getBaseline();
        if (baseline != -1) {
            maxChildBaseline = Math.max(maxChildBaseline, baseline);
            maxChildDescent = Math.max(maxChildDescent, child.getMeasuredHeight() - baseline);
        }
        maxWidth = Math.max(maxWidth, child.getMeasuredWidth());
        maxHeight = Math.max(maxHeight, child.getMeasuredHeight());
        childState = childState | child.getMeasuredState();
    }
    if (maxChildBaseline != -1) {
        maxChildDescent = Math.max(maxChildDescent, getPaddingBottom());
        maxHeight = Math.max(maxHeight, maxChildBaseline + maxChildDescent);
        mBaseline = maxChildBaseline;
    }
    maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
    maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
    setMeasuredDimension(
            View.resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
            View.resolveSizeAndState(maxHeight, heightMeasureSpec,
                    childState << MEASURED_HEIGHT_STATE_SHIFT));
}
 
Example 2
Source File: Utility11.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getMeasuredState(View child) {
    return child.getMeasuredState();
}
 
Example 3
Source File: ViewCompatHC.java    From letv with Apache License 2.0 4 votes vote down vote up
public static int getMeasuredState(View view) {
    return view.getMeasuredState();
}
 
Example 4
Source File: HoneycombUtil.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
public static int getMeasuredState(View view) {
  return view.getMeasuredState();
}
 
Example 5
Source File: ViewFlow.java    From NewXmPluginSDK with Apache License 2.0 4 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
	int widthSize = MeasureSpec.getSize(widthMeasureSpec);
	int heightSize = MeasureSpec.getSize(heightMeasureSpec);
	final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
	final int heightMode = MeasureSpec.getMode(heightMeasureSpec);

	int childWidth = 0;
	int childHeight = 0;
	int childState = 0;

	final int widthPadding = getWidthPadding();
	final int heightPadding = getHeightPadding();

	int count = mAdapter == null ? 0 : mAdapter.getCount();
	if (count > 0) {
		final View child = obtainView(0);
		measureChild(child, widthMeasureSpec, heightMeasureSpec);
		childWidth = child.getMeasuredWidth();
		childHeight = child.getMeasuredHeight();
		if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.ICE_CREAM_SANDWICH)
		childState = child.getMeasuredState();
		mRecycledViews.add(child);
	}

	switch (widthMode) {
		case MeasureSpec.UNSPECIFIED:
			widthSize = childWidth + widthPadding;
			break;
		case MeasureSpec.AT_MOST:
			widthSize = (childWidth + widthPadding) | childState;
			break;
		case MeasureSpec.EXACTLY:
			if (widthSize < childWidth + widthPadding)
				widthSize |= MEASURED_STATE_TOO_SMALL;
			break;
	}
	switch (heightMode) {
		case MeasureSpec.UNSPECIFIED:
			heightSize = childHeight + heightPadding;
			break;
		case MeasureSpec.AT_MOST:
			heightSize = (childHeight + heightPadding) | (childState >> MEASURED_HEIGHT_STATE_SHIFT);
			break;
		case MeasureSpec.EXACTLY:
			if (heightSize < childHeight + heightPadding)
				heightSize |= MEASURED_STATE_TOO_SMALL;
			break;
	}

	if (heightMode == MeasureSpec.UNSPECIFIED) {
		heightSize = heightPadding + childHeight;
	} else {
		heightSize |= (childState&MEASURED_STATE_MASK);
	}

	setMeasuredDimension(widthSize, heightSize);
}
 
Example 6
Source File: ViewCompatHC.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
public static int getMeasuredState(View view) {
    return view.getMeasuredState();
}
 
Example 7
Source File: ViewCompatHC.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
public static int getMeasuredState(View view) {
    return view.getMeasuredState();
}
 
Example 8
Source File: ViewCompatHC.java    From guideshow with MIT License 4 votes vote down vote up
public static int getMeasuredState(View view) {
    return view.getMeasuredState();
}