summaryrefslogtreecommitdiffstats
path: root/core/java/android/text/Layout.java
diff options
context:
space:
mode:
authorRaph Levien <raph@google.com>2015-07-06 18:08:39 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-06 18:08:41 +0000
commit441fc0fc68140368d5438a6eb5b896b4a9d6ad4e (patch)
tree34f48478cd3a7a1ea56805d1d3b3d9983d305a3a /core/java/android/text/Layout.java
parent1a257545b2d1e8bd95393ee6637e70be7d230bc6 (diff)
parent2ea5290ffb9efe0a7c187fb1177ef8ecd089803c (diff)
downloadframeworks_base-441fc0fc68140368d5438a6eb5b896b4a9d6ad4e.zip
frameworks_base-441fc0fc68140368d5438a6eb5b896b4a9d6ad4e.tar.gz
frameworks_base-441fc0fc68140368d5438a6eb5b896b4a9d6ad4e.tar.bz2
Merge "Fix problems with StaticLayout indentation" into mnc-dev
Diffstat (limited to 'core/java/android/text/Layout.java')
-rw-r--r--core/java/android/text/Layout.java29
1 files changed, 19 insertions, 10 deletions
diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java
index f7027f9..d822138 100644
--- a/core/java/android/text/Layout.java
+++ b/core/java/android/text/Layout.java
@@ -385,21 +385,22 @@ public abstract class Layout {
int x;
if (align == Alignment.ALIGN_NORMAL) {
if (dir == DIR_LEFT_TO_RIGHT) {
- x = left;
+ x = left + getIndentAdjust(lineNum, Alignment.ALIGN_LEFT);
} else {
- x = right;
+ x = right + getIndentAdjust(lineNum, Alignment.ALIGN_RIGHT);
}
} else {
int max = (int)getLineExtent(lineNum, tabStops, false);
if (align == Alignment.ALIGN_OPPOSITE) {
if (dir == DIR_LEFT_TO_RIGHT) {
- x = right - max;
+ x = right - max + getIndentAdjust(lineNum, Alignment.ALIGN_RIGHT);
} else {
- x = left - max;
+ x = left - max + getIndentAdjust(lineNum, Alignment.ALIGN_LEFT);
}
} else { // Alignment.ALIGN_CENTER
max = max & ~1;
- x = (right + left - max) >> 1;
+ x = ((right + left - max) >> 1) +
+ getIndentAdjust(lineNum, Alignment.ALIGN_CENTER);
}
}
@@ -545,9 +546,9 @@ public abstract class Layout {
int x;
if (align == Alignment.ALIGN_NORMAL) {
if (dir == DIR_LEFT_TO_RIGHT) {
- x = left;
+ x = left + getIndentAdjust(line, Alignment.ALIGN_LEFT);
} else {
- x = right;
+ x = right + getIndentAdjust(line, Alignment.ALIGN_RIGHT);
}
} else {
TabStops tabStops = null;
@@ -565,14 +566,14 @@ public abstract class Layout {
int max = (int)getLineExtent(line, tabStops, false);
if (align == Alignment.ALIGN_OPPOSITE) {
if (dir == DIR_LEFT_TO_RIGHT) {
- x = right - max;
+ x = right - max + getIndentAdjust(line, Alignment.ALIGN_RIGHT);
} else {
// max is negative here
- x = left - max;
+ x = left - max + getIndentAdjust(line, Alignment.ALIGN_LEFT);
}
} else { // Alignment.ALIGN_CENTER
max = max & ~1;
- x = (left + right - max) >> 1;
+ x = (left + right - max) >> 1 + getIndentAdjust(line, Alignment.ALIGN_CENTER);
}
}
return x;
@@ -745,6 +746,14 @@ public abstract class Layout {
return 0;
}
+ /**
+ * Returns the left indent for a line.
+ *
+ * @hide
+ */
+ public int getIndentAdjust(int line, Alignment alignment) {
+ return 0;
+ }
/**
* Returns true if the character at offset and the preceding character