heightMeasureSpec = widthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize,MeasureSpec.EXACTLY)是什么意思?

时间:2013-07-23 15:39:09

标签: android

在下面的示例代码中,我找到heightMeasureSpec = widthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize,MeasureSpec.EXACTLY)。 代码中有两个“=”,是不是?这是Java语法吗?

   @SuppressWarnings("unused")
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec));

        int childWidthSize = getMeasuredWidth();
        int childHeightSize = getMeasuredHeight();

        heightMeasureSpec = widthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

1 个答案:

答案 0 :(得分:4)

是的,它在Java中是允许的。它将heightMeasureSpecwidthMeasureSpec设置为MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY)返回的值。