android: when linearlayout set weight,should count space when calculate total length

This commit is contained in:
pengfei.zhou 2021-07-29 11:35:46 +08:00 committed by osborn
parent 3b0f13bb99
commit c7e6f93955

View File

@ -854,6 +854,9 @@ public class DoricLinearLayoutCompat extends ViewGroup {
final int totalLength = mTotalLength; final int totalLength = mTotalLength;
mTotalLength = Math.max(totalLength, totalLength + child.getMeasuredHeight() + mTotalLength = Math.max(totalLength, totalLength + child.getMeasuredHeight() +
lp.topMargin + lp.bottomMargin + getNextLocationOffset(child)); lp.topMargin + lp.bottomMargin + getNextLocationOffset(child));
if (hasDividerBeforeChildAt(i)) {
mTotalLength += mDividerHeight;
}
} }
// Add in our padding // Add in our padding
@ -1234,7 +1237,9 @@ public class DoricLinearLayoutCompat extends ViewGroup {
mTotalLength = Math.max(totalLength, totalLength + child.getMeasuredWidth() + mTotalLength = Math.max(totalLength, totalLength + child.getMeasuredWidth() +
lp.leftMargin + lp.rightMargin + getNextLocationOffset(child)); lp.leftMargin + lp.rightMargin + getNextLocationOffset(child));
} }
if (mTotalLength > 0 && hasDividerBeforeChildAt(count)) {
mTotalLength += mDividerWidth;
}
boolean matchHeightLocally = heightMode != MeasureSpec.EXACTLY && boolean matchHeightLocally = heightMode != MeasureSpec.EXACTLY &&
lp.height == LayoutParams.MATCH_PARENT; lp.height == LayoutParams.MATCH_PARENT;