From c7e6f939554a30804932dcb3da2709a7f031e5a6 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Thu, 29 Jul 2021 11:35:46 +0800 Subject: [PATCH] android: when linearlayout set weight,should count space when calculate total length --- .../androidx/appcompat/widget/DoricLinearLayoutCompat.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doric-android/doric/src/main/java/androidx/appcompat/widget/DoricLinearLayoutCompat.java b/doric-android/doric/src/main/java/androidx/appcompat/widget/DoricLinearLayoutCompat.java index 981f4663..9654ab2c 100644 --- a/doric-android/doric/src/main/java/androidx/appcompat/widget/DoricLinearLayoutCompat.java +++ b/doric-android/doric/src/main/java/androidx/appcompat/widget/DoricLinearLayoutCompat.java @@ -854,6 +854,9 @@ public class DoricLinearLayoutCompat extends ViewGroup { final int totalLength = mTotalLength; mTotalLength = Math.max(totalLength, totalLength + child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin + getNextLocationOffset(child)); + if (hasDividerBeforeChildAt(i)) { + mTotalLength += mDividerHeight; + } } // Add in our padding @@ -1234,7 +1237,9 @@ public class DoricLinearLayoutCompat extends ViewGroup { mTotalLength = Math.max(totalLength, totalLength + child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin + getNextLocationOffset(child)); } - + if (mTotalLength > 0 && hasDividerBeforeChildAt(count)) { + mTotalLength += mDividerWidth; + } boolean matchHeightLocally = heightMode != MeasureSpec.EXACTLY && lp.height == LayoutParams.MATCH_PARENT;