summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Raph Levien <raph@google.com> 2014-04-24 12:51:35 -0700
committer Raph Levien <raph@google.com> 2014-04-24 20:00:05 +0000
commita10e19845ce76c0e4dd38018c84b83c9255dc9fe (patch)
treec84d1c12473cb0fe9dea4c2f2ced38ade180d940
parent03981a4c2e9689197e4d2c916c07ae16207b5276 (diff)
Followon fix for 14276128 Clipping at bottom of TextView
The previous fix did not work when the text was ellipsized, because the test for whether the line was the last line was incorrect. The new test handles both the end of the buffer and the case where it is the last line because of ellipsizing. So this should be the proper fix for bug 14276128 Clipping at bottom of TextView when lineSpacingMultiplier < 1 Change-Id: Iac5c96f2273142031c18a27f504f7d6d5fcf823e
-rw-r--r--core/java/android/text/StaticLayout.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index 1f32d4d008ca..814326c3ba3f 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -633,7 +633,11 @@ public class StaticLayout extends Layout {
bottom = fm.bottom;
}
- if (j == 0) {
+ boolean firstLine = (j == 0);
+ boolean currentLineIsTheLastVisibleOne = (j + 1 == mMaximumVisibleLineCount);
+ boolean lastLine = currentLineIsTheLastVisibleOne || (end == bufEnd);
+
+ if (firstLine) {
if (trackPad) {
mTopPadding = top - above;
}
@@ -642,7 +646,10 @@ public class StaticLayout extends Layout {
above = top;
}
}
- if (end == bufEnd) {
+
+ int extra;
+
+ if (lastLine) {
if (trackPad) {
mBottomPadding = bottom - below;
}
@@ -652,9 +659,8 @@ public class StaticLayout extends Layout {
}
}
- int extra;
- if (needMultiply && end != bufEnd) {
+ if (needMultiply && !lastLine) {
double ex = (below - above) * (spacingmult - 1) + spacingadd;
if (ex >= 0) {
extra = (int)(ex + EXTRA_ROUNDING);
@@ -691,8 +697,6 @@ public class StaticLayout extends Layout {
if (ellipsize != null) {
// If there is only one line, then do any type of ellipsis except when it is MARQUEE
// if there are multiple lines, just allow END ellipsis on the last line
- boolean firstLine = (j == 0);
- boolean currentLineIsTheLastVisibleOne = (j + 1 == mMaximumVisibleLineCount);
boolean forceEllipsis = moreChars && (mLineCount + 1 == mMaximumVisibleLineCount);
boolean doEllipsis =