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

The following examples show how to use android.view.View#getMeasuredState() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
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
@Override
public int getMeasuredState(View child) {
    return child.getMeasuredState();
}
 
Example 3
Source Project: letv   File: ViewCompatHC.java    License: Apache License 2.0 4 votes vote down vote up
public static int getMeasuredState(View view) {
    return view.getMeasuredState();
}
 
Example 4
public static int getMeasuredState(View view) {
  return view.getMeasuredState();
}
 
Example 5
Source Project: NewXmPluginSDK   File: ViewFlow.java    License: 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
public static int getMeasuredState(View view) {
    return view.getMeasuredState();
}
 
Example 7
Source Project: V.FlyoutTest   File: ViewCompatHC.java    License: MIT License 4 votes vote down vote up
public static int getMeasuredState(View view) {
    return view.getMeasuredState();
}
 
Example 8
Source Project: guideshow   File: ViewCompatHC.java    License: MIT License 4 votes vote down vote up
public static int getMeasuredState(View view) {
    return view.getMeasuredState();
}