Merge "Fix bug #7621927 Radio button/TextView drawable regression in 4.2" into jb-mr1.1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
71175f727b
@@ -248,6 +248,15 @@ public abstract class CompoundButton extends Button implements Checkable {
|
||||
return padding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getHorizontalOffsetForDrawables() {
|
||||
final Drawable buttonDrawable = mButtonDrawable;
|
||||
return (buttonDrawable != null) ? buttonDrawable.getIntrinsicWidth() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
|
||||
@@ -4863,6 +4863,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
return highlight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public int getHorizontalOffsetForDrawables() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
restartMarqueeIfNeeded();
|
||||
@@ -4880,6 +4887,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
final int left = mLeft;
|
||||
final int bottom = mBottom;
|
||||
final int top = mTop;
|
||||
final boolean isLayoutRtl = isLayoutRtl();
|
||||
final int offset = getHorizontalOffsetForDrawables();
|
||||
final int leftOffset = isLayoutRtl ? 0 : offset;
|
||||
final int rightOffset = isLayoutRtl ? offset : 0 ;
|
||||
|
||||
final Drawables dr = mDrawables;
|
||||
if (dr != null) {
|
||||
@@ -4895,7 +4906,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
// Make sure to update invalidateDrawable() when changing this code.
|
||||
if (dr.mDrawableLeft != null) {
|
||||
canvas.save();
|
||||
canvas.translate(scrollX + mPaddingLeft,
|
||||
canvas.translate(scrollX + mPaddingLeft + leftOffset,
|
||||
scrollY + compoundPaddingTop +
|
||||
(vspace - dr.mDrawableHeightLeft) / 2);
|
||||
dr.mDrawableLeft.draw(canvas);
|
||||
@@ -4906,7 +4917,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
// Make sure to update invalidateDrawable() when changing this code.
|
||||
if (dr.mDrawableRight != null) {
|
||||
canvas.save();
|
||||
canvas.translate(scrollX + right - left - mPaddingRight - dr.mDrawableSizeRight,
|
||||
canvas.translate(scrollX + right - left - mPaddingRight
|
||||
- dr.mDrawableSizeRight - rightOffset,
|
||||
scrollY + compoundPaddingTop + (vspace - dr.mDrawableHeightRight) / 2);
|
||||
dr.mDrawableRight.draw(canvas);
|
||||
canvas.restore();
|
||||
@@ -4991,8 +5003,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
}
|
||||
canvas.translate(compoundPaddingLeft, extendedPaddingTop + voffsetText);
|
||||
|
||||
final boolean isLayoutRtl = isLayoutRtl();
|
||||
|
||||
final int layoutDirection = getLayoutDirection();
|
||||
final int absoluteGravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection);
|
||||
if (mEllipsize == TextUtils.TruncateAt.MARQUEE &&
|
||||
|
||||
Reference in New Issue
Block a user