diff options
Diffstat (limited to 'core/java/android/text/StaticLayout.java')
-rw-r--r-- | core/java/android/text/StaticLayout.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index 2bcb352..67794b1 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -165,6 +165,19 @@ public class StaticLayout extends Layout { return this; } + public Builder setIndents(int[] leftIndents, int[] rightIndents) { + int leftLen = leftIndents == null ? 0 : leftIndents.length; + int rightLen = rightIndents == null ? 0 : rightIndents.length; + int[] indents = new int[Math.max(leftLen, rightLen)]; + for (int i = 0; i < indents.length; i++) { + int leftMargin = i < leftLen ? leftIndents[i] : 0; + int rightMargin = i < rightLen ? rightIndents[i] : 0; + indents[i] = leftMargin + rightMargin; + } + nSetIndents(mNativePtr, indents); + return this; + } + /** * Measurement and break iteration is done in native code. The protocol for using * the native code is as follows. @@ -811,7 +824,7 @@ public class StaticLayout extends Layout { float sum = 0; int i; - for (i = len; i >= 0; i--) { + for (i = len; i > 0; i--) { float w = widths[i - 1 + lineStart - widthStart]; if (w + sum + ellipsisWidth > avail) { @@ -1009,6 +1022,8 @@ public class StaticLayout extends Layout { private static native void nSetLocale(long nativePtr, String locale, long nativeHyphenator); + private static native void nSetIndents(long nativePtr, int[] indents); + // Set up paragraph text and settings; done as one big method to minimize jni crossings private static native void nSetupParagraph(long nativePtr, char[] text, int length, float firstWidth, int firstWidthLineCount, float restWidth, |