当前位置: 首页>>代码示例>>Java>>正文


Java View.MEASURED_STATE_MASK属性代码示例

本文整理汇总了Java中android.view.View.MEASURED_STATE_MASK属性的典型用法代码示例。如果您正苦于以下问题:Java View.MEASURED_STATE_MASK属性的具体用法?Java View.MEASURED_STATE_MASK怎么用?Java View.MEASURED_STATE_MASK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.view.View的用法示例。


在下文中一共展示了View.MEASURED_STATE_MASK属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: measureCombinedMainTextViewsWidthAndState

private int measureCombinedMainTextViewsWidthAndState(int maxWidth, int widthMode) {
    int combinedChildMeasuredStates = 0;
    int maxRequiredTextWidth = 0;

    for (int i = 0; i < mChildsMainText.length; i++) {
        View textView = mChildsMainText[i];
        if (!takesSpace(textView))
            continue;

        measureChild(textView, MeasureSpec.makeMeasureSpec(maxWidth, widthMode),
                mHeightMeasureSpecsMainText[i]);
        int measuredWidthAndState = textView.getMeasuredWidthAndState();

        combinedChildMeasuredStates = combineMeasuredStates(combinedChildMeasuredStates,
                measuredWidthAndState);
        maxRequiredTextWidth = Math.max(maxRequiredTextWidth,
                measuredWidthAndState & View.MEASURED_SIZE_MASK);
    }
    return (combinedChildMeasuredStates & View.MEASURED_STATE_MASK) | maxRequiredTextWidth;
}
 
开发者ID:schul-cloud,项目名称:schulcloud-mobile-android,代码行数:20,代码来源:ListItemLayout.java

示例2: onMeasure

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // Fix if textSecondary2 is set, but textSecondary isn't
    if (mChildTextSecondary == null && mChildTextSecondary2 != null) {
        mChildTextSecondary = mChildTextSecondary2;
        mChildTextSecondary2 = null;
    }

    Resources res = getResources();
    int totalExtrasWidth = getTotalHorizontalPadding();

    // Set required height
    int heightRes;
    if (!takesSpace(mChildTextSecondary2))
        if (!takesSpace(mChildTextSecondary))
            if (!takesSpace(mChildAvatar))
                heightRes = R.dimen.material_listItemLayout_height;
            else
                heightRes = R.dimen.material_listItemLayout_height_singleLineWithAvatar;
        else
            heightRes = R.dimen.material_listItemLayout_height_twoLine;
    else
        heightRes = R.dimen.material_listItemLayout_height_threeLine;
    int height = getResources().getDimensionPixelSize(heightRes)
            + getPaddingTop() + getPaddingBottom();

    // Avatar
    int text_offsetStart_withStartDetail = res.getDimensionPixelSize(
            R.dimen.material_listItemLayout_text_offsetStart_withStartDetail);
    if (takesSpace(mChildAvatar)) {
        totalExtrasWidth += text_offsetStart_withStartDetail;
        measureChild(mChildAvatar, mAvatar_measureSpec, mAvatar_measureSpec);
    } else if (takesSpace(mChildStartIcon)) {
        totalExtrasWidth += text_offsetStart_withStartDetail;
        measureChild(mChildStartIcon, mStartIcon_measureSpec, mStartIcon_measureSpec);
    }

    // End icon/end texts
    if (takesSpace(mChildEndIcon)) {
        totalExtrasWidth += res.getDimensionPixelSize(
                R.dimen.material_listItemLayout_text_offsetEnd_withEndIcon);
        measureChild(mChildEndIcon, mEndIcon_measureSpec, mEndIcon_measureSpec);
    } else if (takesSpace(mChildEndTextTop) || takesSpace(mChildEndTextBottom)) {
        totalExtrasWidth += res.getDimensionPixelOffset(
                R.dimen.material_listItemLayout_text_offsetEnd_withEndText);
        if (takesSpace(mChildEndTextTop))
            mChildEndTextTop.measure(mEndText_measureSpecWidth, mEndText_measureSpecHeight);
        if (takesSpace(mChildEndTextBottom))
            mChildEndTextBottom.measure(mEndText_measureSpecWidth, mEndText_measureSpecHeight);
    }

    // Main texts
    int combinedTextWidthAndState = measureCombinedMainTextViewsWidthAndState(
            MeasureSpec.getSize(widthMeasureSpec) - totalExtrasWidth,
            MeasureSpec.getMode(widthMeasureSpec));
    int combinedChildMeasuredStates = combinedTextWidthAndState & View.MEASURED_STATE_MASK;
    int maxRequiredTextWidth = combinedTextWidthAndState & View.MEASURED_SIZE_MASK;

    setMeasuredDimension(
            resolveSizeAndState(totalExtrasWidth + maxRequiredTextWidth,
                    widthMeasureSpec, combinedChildMeasuredStates),
            resolveSizeAndState(height, heightMeasureSpec, 0));
}
 
开发者ID:schul-cloud,项目名称:schulcloud-mobile-android,代码行数:63,代码来源:ListItemLayout.java

示例3: getMeasuredStateInt

/**
 * Return only the state bits of {@link #getMeasuredWidthAndState()}
 * and {@link #getMeasuredHeightAndState()}, combined into one integer.
 * The width component is in the regular bits {@link #MEASURED_STATE_MASK}
 * and the height component is at the shifted bits
 * {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}.
 */
public static int getMeasuredStateInt(View child) {
    return (child.getMeasuredWidth()&View.MEASURED_STATE_MASK)
            | ((child.getMeasuredHeight()>>View.MEASURED_HEIGHT_STATE_SHIFT)
                    & (View.MEASURED_STATE_MASK>>View.MEASURED_HEIGHT_STATE_SHIFT));
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:12,代码来源:IcsView.java


注:本文中的android.view.View.MEASURED_STATE_MASK属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。