diff options
| author | Raph Levien <raph@google.com> | 2014-11-13 12:36:49 -0800 |
|---|---|---|
| committer | Raph Levien <raph@google.com> | 2014-11-13 12:48:40 -0800 |
| commit | 44cb2432e90c7a9e0ee59b959d781ba8834c1736 (patch) | |
| tree | feb02de1ab0e66cd43339d5dbadc2a5893f3fdc6 /core/java/android/widget/TextView.java | |
| parent | 705c9c131a6df977a2e9430cacb84788ef0cecbf (diff) | |
Fudge clipRect in TextView for extra cursor width
There are a number of cases (most commonly cursor at start of line in
RTL direction) where the cursor extends past the right edge of the
clipRect. This patch adds approximately 1dp on the right side of the
clip, so that the cursor doesn't get clipped.
Bug: 18035274
Change-Id: I489825a91750742c28e445f54f9d27000accbcfb
Diffstat (limited to 'core/java/android/widget/TextView.java')
| -rw-r--r-- | core/java/android/widget/TextView.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 0917b32e89d4..b67bbdb62b40 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -5368,9 +5368,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop; final int maxScrollY = mLayout.getHeight() - vspace; + // Add sufficient space for cursor and tone marks + int cursorWidth = 2 + (int)mTextPaint.density; // adequate for Material cursors + int fudgedPaddingRight = Math.max(0, compoundPaddingRight - (cursorWidth - 1)); + float clipLeft = compoundPaddingLeft + scrollX; float clipTop = (scrollY == 0) ? 0 : extendedPaddingTop + scrollY; - float clipRight = right - left - compoundPaddingRight + scrollX; + float clipRight = right - left - fudgedPaddingRight + scrollX; float clipBottom = bottom - top + scrollY - ((scrollY == maxScrollY) ? 0 : extendedPaddingBottom); |
