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


Java ViewCompat.combineMeasuredStates方法代码示例

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


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

示例1: onMeasure

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    prepareChildren();
    ensurePreDrawListener();
    int paddingLeft = getPaddingLeft();
    int paddingTop = getPaddingTop();
    int paddingRight = getPaddingRight();
    int paddingBottom = getPaddingBottom();
    int layoutDirection = ViewCompat.getLayoutDirection(this);
    boolean isRtl = layoutDirection == 1;
    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);
    int widthPadding = paddingLeft + paddingRight;
    int heightPadding = paddingTop + paddingBottom;
    int widthUsed = getSuggestedMinimumWidth();
    int heightUsed = getSuggestedMinimumHeight();
    int childState = 0;
    boolean applyInsets = this.mLastInsets != null && ViewCompat.getFitsSystemWindows(this);
    int childCount = this.mDependencySortedChildren.size();
    for (int i = 0; i < childCount; i++) {
        View child = (View) this.mDependencySortedChildren.get(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        int keylineWidthUsed = 0;
        if (lp.keyline >= 0 && widthMode != 0) {
            int keylinePos = getKeyline(lp.keyline);
            int keylineGravity = GravityCompat.getAbsoluteGravity(resolveKeylineGravity(lp.gravity), layoutDirection) & 7;
            if ((keylineGravity == 3 && !isRtl) || (keylineGravity == 5 && isRtl)) {
                keylineWidthUsed = Math.max(0, (widthSize - paddingRight) - keylinePos);
            } else if ((keylineGravity == 5 && !isRtl) || (keylineGravity == 3 && isRtl)) {
                keylineWidthUsed = Math.max(0, keylinePos - paddingLeft);
            }
        }
        int childWidthMeasureSpec = widthMeasureSpec;
        int childHeightMeasureSpec = heightMeasureSpec;
        if (applyInsets && !ViewCompat.getFitsSystemWindows(child)) {
            int vertInsets = this.mLastInsets.getSystemWindowInsetTop() + this.mLastInsets.getSystemWindowInsetBottom();
            childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize - (this.mLastInsets.getSystemWindowInsetLeft() + this.mLastInsets.getSystemWindowInsetRight()), widthMode);
            childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize - vertInsets, heightMode);
        }
        Behavior b = lp.getBehavior();
        if (b == null || !b.onMeasureChild(this, child, childWidthMeasureSpec, keylineWidthUsed, childHeightMeasureSpec, 0)) {
            onMeasureChild(child, childWidthMeasureSpec, keylineWidthUsed, childHeightMeasureSpec, 0);
        }
        widthUsed = Math.max(widthUsed, ((child.getMeasuredWidth() + widthPadding) + lp.leftMargin) + lp.rightMargin);
        heightUsed = Math.max(heightUsed, ((child.getMeasuredHeight() + heightPadding) + lp.topMargin) + lp.bottomMargin);
        childState = ViewCompat.combineMeasuredStates(childState, ViewCompat.getMeasuredState(child));
    }
    setMeasuredDimension(ViewCompat.resolveSizeAndState(widthUsed, widthMeasureSpec, -16777216 & childState), ViewCompat.resolveSizeAndState(heightUsed, heightMeasureSpec, childState << 16));
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:51,代码来源:CoordinatorLayout.java


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