0

在以下示例代码中,我发现 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);
    }
4

1 回答 1

4

是的,它在 Java 中是允许的。它同时设置heightMeasureSpec和设置widthMeasureSpec从返回的值MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY)

于 2013-07-23T15:53:27.200 回答