StaticLayout visual fix for maxLines
When maxLines is set on StaticLayout, the height calculation includes
the lineSpacing for the lastLine, which causes the ellipsized version
and non-ellipsized version to have different heights. With this CL:
* maxLines is always set on StaticLayout
* the correct line count for a given text is preserved, in other words a
text that would be n lines will not be cut at maxLines.
* The visual height for StaticLayout for ellipsized and non-ellipsized
cases are the same when maxLines is set.
Bug: 28988744
Bug: 18864800
Change-Id: I1e1cae31cf33d503a8cf1c942f422893efc480bb
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index 0bd5071..9761a0c 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -616,6 +616,17 @@
}
/**
+ * Return the total height of this layout.
+ *
+ * @param cap if true and max lines is set, returns the height of the layout at the max lines.
+ *
+ * @hide
+ */
+ public int getHeight(boolean cap) {
+ return getHeight();
+ }
+
+ /**
* Return the base alignment of this layout.
*/
public final Alignment getAlignment() {