diff options
| author | 2012-07-26 15:17:16 -0700 | |
|---|---|---|
| committer | 2012-07-26 16:54:06 -0700 | |
| commit | e2386c184a75b15a0fe7e3791e7ad06d59be7c80 (patch) | |
| tree | b8f7e711cb8cb538d34247006a66db4e540f6b67 | |
| parent | 2b8c4b076d24bc7464e9be63946e8c7bd27bb360 (diff) | |
Make CheckedTextView RTL aware - DO NOT MERGE
- see bug #5429822 UI should be mirrored for RTL locales (Arabic, Hebrew, farsi)
Change-Id: Ic647e105571e01e9773e4c27e9f52997d24c408e
| -rw-r--r-- | core/java/android/widget/CheckedTextView.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java index 61935c2b2024..46079f937201 100644 --- a/core/java/android/widget/CheckedTextView.java +++ b/core/java/android/widget/CheckedTextView.java @@ -174,7 +174,11 @@ public class CheckedTextView extends TextView implements Checkable { int newPadding = (mCheckMarkDrawable != null) ? mCheckMarkWidth + mBasePadding : mBasePadding; mNeedRequestlayout |= (mPaddingRight != newPadding); - mPaddingRight = newPadding; + if (isLayoutRtl()) { + mPaddingLeft = newPadding; + } else { + mPaddingRight = newPadding; + } if (mNeedRequestlayout) { requestLayout(); mNeedRequestlayout = false; @@ -184,7 +188,7 @@ public class CheckedTextView extends TextView implements Checkable { @Override public void setPadding(int left, int top, int right, int bottom) { super.setPadding(left, top, right, bottom); - mBasePadding = mPaddingRight; + mBasePadding = getPaddingEnd(); } @Override @@ -213,12 +217,13 @@ public class CheckedTextView extends TextView implements Checkable { break; } - int right = getWidth(); - checkMarkDrawable.setBounds( - right - mPaddingRight, - y, - right - mPaddingRight + mCheckMarkWidth, - y + height); + final boolean isLayoutRtl = isLayoutRtl(); + final int width = getWidth(); + final int top = y; + final int bottom = top + height; + final int left = isLayoutRtl ? getPaddingEnd() : width - getPaddingEnd(); + final int right = left + mCheckMarkWidth; + checkMarkDrawable.setBounds( left, top, right, bottom); checkMarkDrawable.draw(canvas); } } |