diff options
| -rw-r--r-- | core/java/android/widget/TextView.java | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b7fbc0ec8186..40a72a417936 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -3711,34 +3711,36 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // for each compound drawable in onDraw(). Make sure to update each section // accordingly. final TextView.Drawables drawables = mDrawables; - if (drawable == drawables.mDrawableLeft) { - final int compoundPaddingTop = getCompoundPaddingTop(); - final int compoundPaddingBottom = getCompoundPaddingBottom(); - final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop; - - scrollX += mPaddingLeft; - scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightLeft) / 2; - } else if (drawable == drawables.mDrawableRight) { - final int compoundPaddingTop = getCompoundPaddingTop(); - final int compoundPaddingBottom = getCompoundPaddingBottom(); - final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop; - - scrollX += (mRight - mLeft - mPaddingRight - drawables.mDrawableSizeRight); - scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightRight) / 2; - } else if (drawable == drawables.mDrawableTop) { - final int compoundPaddingLeft = getCompoundPaddingLeft(); - final int compoundPaddingRight = getCompoundPaddingRight(); - final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft; - - scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthTop) / 2; - scrollY += mPaddingTop; - } else if (drawable == drawables.mDrawableBottom) { - final int compoundPaddingLeft = getCompoundPaddingLeft(); - final int compoundPaddingRight = getCompoundPaddingRight(); - final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft; - - scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthBottom) / 2; - scrollY += (mBottom - mTop - mPaddingBottom - drawables.mDrawableSizeBottom); + if (drawables != null) { + if (drawable == drawables.mDrawableLeft) { + final int compoundPaddingTop = getCompoundPaddingTop(); + final int compoundPaddingBottom = getCompoundPaddingBottom(); + final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop; + + scrollX += mPaddingLeft; + scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightLeft) / 2; + } else if (drawable == drawables.mDrawableRight) { + final int compoundPaddingTop = getCompoundPaddingTop(); + final int compoundPaddingBottom = getCompoundPaddingBottom(); + final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop; + + scrollX += (mRight - mLeft - mPaddingRight - drawables.mDrawableSizeRight); + scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightRight) / 2; + } else if (drawable == drawables.mDrawableTop) { + final int compoundPaddingLeft = getCompoundPaddingLeft(); + final int compoundPaddingRight = getCompoundPaddingRight(); + final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft; + + scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthTop) / 2; + scrollY += mPaddingTop; + } else if (drawable == drawables.mDrawableBottom) { + final int compoundPaddingLeft = getCompoundPaddingLeft(); + final int compoundPaddingRight = getCompoundPaddingRight(); + final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft; + + scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthBottom) / 2; + scrollY += (mBottom - mTop - mPaddingBottom - drawables.mDrawableSizeBottom); + } } invalidate(dirty.left + scrollX, dirty.top + scrollY, |