Fix bug #5979311 Change TextView to not clip top/bottom text
Change-Id: I40a2ef40e540f20a9f626ab2e4e6e39fd062c9fe
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 164bc64..971d910 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4834,10 +4834,14 @@
int extendedPaddingTop = getExtendedPaddingTop();
int extendedPaddingBottom = getExtendedPaddingBottom();
+ final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop;
+ final int maxScrollY = mLayout.getHeight() - vspace;
+
float clipLeft = compoundPaddingLeft + scrollX;
- float clipTop = extendedPaddingTop + scrollY;
+ float clipTop = (scrollY == 0) ? 0 : extendedPaddingTop + scrollY;
float clipRight = right - left - compoundPaddingRight + scrollX;
- float clipBottom = bottom - top - extendedPaddingBottom + scrollY;
+ float clipBottom = bottom - top + scrollY -
+ ((scrollY == maxScrollY) ? 0 : extendedPaddingBottom);
if (mShadowRadius != 0) {
clipLeft += Math.min(0, mShadowDx - mShadowRadius);