From 07e6c237d3f19b98bbec237892a785fd3895368a Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Mon, 4 Apr 2016 12:34:06 -0700 Subject: [PATCH] Apply correct bottom padding to layouts The returned descender value for BoringLayout and StaticLayout should be equal to the font's "bottom" metric in the includePadding case. Previously, the calculation incorrectly included an addition mBottomPadding value in some cases (which was an attempt to work around the case where maxLines was set on TextView but not the corresponding StaticLayout, no longer the case). Bug: 27901763 Change-Id: I008c5974b979087725a9bb9104e4771b0caac01c --- core/java/android/text/BoringLayout.java | 4 ++-- core/java/android/text/StaticLayout.java | 14 ++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/core/java/android/text/BoringLayout.java b/core/java/android/text/BoringLayout.java index 328fe99a7f936..7f0021d729d05 100644 --- a/core/java/android/text/BoringLayout.java +++ b/core/java/android/text/BoringLayout.java @@ -183,8 +183,10 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback if (includepad) { spacing = metrics.bottom - metrics.top; + mDesc = metrics.bottom; } else { spacing = metrics.descent - metrics.ascent; + mDesc = metrics.descent; } mBottom = spacing; @@ -208,8 +210,6 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback mTopPadding = metrics.top - metrics.ascent; mBottomPadding = metrics.bottom - metrics.descent; } - - mDesc = spacing + mBottomPadding + (includepad ? metrics.top : metrics.ascent); } /** diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index 6a33579153bc6..94ce57ac7cb9f 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -1132,22 +1132,12 @@ public class StaticLayout extends Layout { @Override public int getLineTop(int line) { - int top = mLines[mColumns * line + TOP]; - if (mMaximumVisibleLineCount > 0 && line >= mMaximumVisibleLineCount && - line != mLineCount) { - top += getBottomPadding(); - } - return top; + return mLines[mColumns * line + TOP]; } @Override public int getLineDescent(int line) { - int descent = mLines[mColumns * line + DESCENT]; - if (mMaximumVisibleLineCount > 0 && line >= mMaximumVisibleLineCount - 1 && // -1 intended - line != mLineCount) { - descent += getBottomPadding(); - } - return descent; + return mLines[mColumns * line + DESCENT]; } @Override