summaryrefslogtreecommitdiff
path: root/core/java/android/widget/TextView.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/widget/TextView.java')
-rw-r--r--core/java/android/widget/TextView.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index ca6e735f86b4..f5c1bcf2de42 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -11857,6 +11857,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (text != null) {
if (expandedTopChar > 0 || expandedBottomChar < text.length()) {
+ // Cap the offsets to avoid an OOB exception. That can happen if the
+ // displayed/layout text, on which these offsets are calculated, is longer
+ // than the original text (such as when the view is translated by the
+ // platform intelligence).
+ // TODO(b/196433694): Figure out how to better handle the offset
+ // calculations for this case (so we don't unnecessarily cutoff the original
+ // text, for example).
+ expandedTopChar = Math.min(expandedTopChar, text.length());
+ expandedBottomChar = Math.min(expandedBottomChar, text.length());
text = text.subSequence(expandedTopChar, expandedBottomChar);
}