diff options
| author | 2018-04-12 17:45:29 -0700 | |
|---|---|---|
| committer | 2018-04-12 17:45:29 -0700 | |
| commit | fc7036cb2127b51de50277231ad2f877a0c2d8db (patch) | |
| tree | e5c1c232707ce42a6bcc302c041360ec2d2f1b52 | |
| parent | fcbbb726033a2846201cbe60f4eacbcfdc30f20c (diff) | |
Fix measurement of list with single item
Change-Id: I2474410b7374155bbbe5de0c757e9017f52746e5
Fixes: 72656378
Test: visual
| -rw-r--r-- | core/java/com/android/internal/widget/NotificationActionListLayout.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/core/java/com/android/internal/widget/NotificationActionListLayout.java b/core/java/com/android/internal/widget/NotificationActionListLayout.java index e013553ec046..21dcd9a62851 100644 --- a/core/java/com/android/internal/widget/NotificationActionListLayout.java +++ b/core/java/com/android/internal/widget/NotificationActionListLayout.java @@ -107,21 +107,23 @@ public class NotificationActionListLayout extends LinearLayout { } } } - if (notGoneChildren > 1 && needRebuild) { + boolean centerAligned = (mGravity & Gravity.CENTER_HORIZONTAL) != 0; + boolean singleChildCentered = notGoneChildren == 1 && centerAligned; + boolean needsRegularMeasurement = notGoneChildren > 1 || singleChildCentered; + + if (needsRegularMeasurement && needRebuild) { rebuildMeasureOrder(textViews, otherViews); } final boolean constrained = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.UNSPECIFIED; - final boolean centerAligned = (mGravity & Gravity.CENTER_HORIZONTAL) != 0; final int innerWidth = MeasureSpec.getSize(widthMeasureSpec) - mPaddingLeft - mPaddingRight; final int otherSize = mMeasureOrderOther.size(); int usedWidth = 0; - // Optimization: Don't do this if there's only one child. int measuredChildren = 0; - for (int i = 0; i < N && notGoneChildren > 1; i++) { + for (int i = 0; i < N && needsRegularMeasurement; i++) { // Measure shortest children first. To avoid measuring twice, we approximate by looking // at the text length. View c; |