Merge "Fix again bug #6887370 ListPreference shows misaligned radio drawables (in CheckedTextView?)" into jb-mr1-dev

This commit is contained in:
Fabrice Di Meglio
2012-08-24 16:11:19 -07:00
committed by Android (Google) Code Review

View File

@@ -175,11 +175,7 @@ public class CheckedTextView extends TextView implements Checkable {
@Override @Override
protected void internalSetPadding(int left, int top, int right, int bottom) { protected void internalSetPadding(int left, int top, int right, int bottom) {
super.internalSetPadding(left, top, right, bottom); super.internalSetPadding(left, top, right, bottom);
if (isLayoutRtl()) { setBasePadding(isLayoutRtl());
mBasePadding = mUserPaddingLeft;
} else {
mBasePadding = mUserPaddingRight;
}
} }
@Override @Override
@@ -201,13 +197,21 @@ public class CheckedTextView extends TextView implements Checkable {
@Override @Override
public void setPadding(int left, int top, int right, int bottom) { public void setPadding(int left, int top, int right, int bottom) {
super.setPadding(left, top, right, bottom); super.setPadding(left, top, right, bottom);
mBasePadding = getPaddingEnd(); setBasePadding(isLayoutRtl());
} }
@Override @Override
public void setPaddingRelative(int start, int top, int end, int bottom) { public void setPaddingRelative(int start, int top, int end, int bottom) {
super.setPaddingRelative(start, top, end, bottom); super.setPaddingRelative(start, top, end, bottom);
mBasePadding = getPaddingEnd(); setBasePadding(isLayoutRtl());
}
private void setBasePadding(boolean isLayoutRtl) {
if (isLayoutRtl) {
mBasePadding = mPaddingLeft;
} else {
mBasePadding = mPaddingRight;
}
} }
@Override @Override
@@ -237,11 +241,11 @@ public class CheckedTextView extends TextView implements Checkable {
final int left; final int left;
final int right; final int right;
if (isLayoutRtl) { if (isLayoutRtl) {
right = getPaddingEnd(); left = mBasePadding;
left = right - mCheckMarkWidth;
} else {
left = width - getPaddingEnd();
right = left + mCheckMarkWidth; right = left + mCheckMarkWidth;
} else {
right = width - mBasePadding;
left = right - mCheckMarkWidth;
} }
checkMarkDrawable.setBounds( left, top, right, bottom); checkMarkDrawable.setBounds( left, top, right, bottom);
checkMarkDrawable.draw(canvas); checkMarkDrawable.draw(canvas);