Loading core/java/android/widget/CompoundButton.java +33 −6 Original line number Diff line number Diff line Loading @@ -224,6 +224,30 @@ public abstract class CompoundButton extends Button implements Checkable { info.setChecked(mChecked); } @Override public int getCompoundPaddingLeft() { int padding = super.getCompoundPaddingLeft(); if (!isLayoutRtl()) { final Drawable buttonDrawable = mButtonDrawable; if (buttonDrawable != null) { padding += buttonDrawable.getIntrinsicWidth(); } } return padding; } @Override public int getCompoundPaddingRight() { int padding = super.getCompoundPaddingRight(); if (isLayoutRtl()) { final Drawable buttonDrawable = mButtonDrawable; if (buttonDrawable != null) { padding += buttonDrawable.getIntrinsicWidth(); } } return padding; } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Loading @@ -231,20 +255,23 @@ public abstract class CompoundButton extends Button implements Checkable { final Drawable buttonDrawable = mButtonDrawable; if (buttonDrawable != null) { final int verticalGravity = getGravity() & Gravity.VERTICAL_GRAVITY_MASK; final int height = buttonDrawable.getIntrinsicHeight(); int y = 0; final int drawableHeight = buttonDrawable.getIntrinsicHeight(); final int drawableWidth = buttonDrawable.getIntrinsicWidth(); int top = 0; switch (verticalGravity) { case Gravity.BOTTOM: y = getHeight() - height; top = getHeight() - drawableHeight; break; case Gravity.CENTER_VERTICAL: y = (getHeight() - height) / 2; top = (getHeight() - drawableHeight) / 2; break; } int bottom = top + drawableHeight; int left = isLayoutRtl() ? getWidth() - drawableWidth : 0; int right = isLayoutRtl() ? getWidth() : drawableWidth; buttonDrawable.setBounds(0, y, buttonDrawable.getIntrinsicWidth(), y + height); buttonDrawable.setBounds(left, top, right, bottom); buttonDrawable.draw(canvas); } } Loading core/res/res/values/styles.xml +0 −3 Original line number Diff line number Diff line Loading @@ -343,17 +343,14 @@ please see styles_device_defaults.xml. </style> <style name="Widget.CompoundButton.CheckBox"> <item name="android:background">@android:drawable/btn_check_label_background</item> <item name="android:button">?android:attr/listChoiceIndicatorMultiple</item> </style> <style name="Widget.CompoundButton.RadioButton"> <item name="android:background">@android:drawable/btn_radio_label_background</item> <item name="android:button">?android:attr/listChoiceIndicatorSingle</item> </style> <style name="Widget.CompoundButton.Star"> <item name="android:background">@android:drawable/btn_star_label_background</item> <item name="android:button">@android:drawable/btn_star</item> </style> Loading Loading
core/java/android/widget/CompoundButton.java +33 −6 Original line number Diff line number Diff line Loading @@ -224,6 +224,30 @@ public abstract class CompoundButton extends Button implements Checkable { info.setChecked(mChecked); } @Override public int getCompoundPaddingLeft() { int padding = super.getCompoundPaddingLeft(); if (!isLayoutRtl()) { final Drawable buttonDrawable = mButtonDrawable; if (buttonDrawable != null) { padding += buttonDrawable.getIntrinsicWidth(); } } return padding; } @Override public int getCompoundPaddingRight() { int padding = super.getCompoundPaddingRight(); if (isLayoutRtl()) { final Drawable buttonDrawable = mButtonDrawable; if (buttonDrawable != null) { padding += buttonDrawable.getIntrinsicWidth(); } } return padding; } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Loading @@ -231,20 +255,23 @@ public abstract class CompoundButton extends Button implements Checkable { final Drawable buttonDrawable = mButtonDrawable; if (buttonDrawable != null) { final int verticalGravity = getGravity() & Gravity.VERTICAL_GRAVITY_MASK; final int height = buttonDrawable.getIntrinsicHeight(); int y = 0; final int drawableHeight = buttonDrawable.getIntrinsicHeight(); final int drawableWidth = buttonDrawable.getIntrinsicWidth(); int top = 0; switch (verticalGravity) { case Gravity.BOTTOM: y = getHeight() - height; top = getHeight() - drawableHeight; break; case Gravity.CENTER_VERTICAL: y = (getHeight() - height) / 2; top = (getHeight() - drawableHeight) / 2; break; } int bottom = top + drawableHeight; int left = isLayoutRtl() ? getWidth() - drawableWidth : 0; int right = isLayoutRtl() ? getWidth() : drawableWidth; buttonDrawable.setBounds(0, y, buttonDrawable.getIntrinsicWidth(), y + height); buttonDrawable.setBounds(left, top, right, bottom); buttonDrawable.draw(canvas); } } Loading
core/res/res/values/styles.xml +0 −3 Original line number Diff line number Diff line Loading @@ -343,17 +343,14 @@ please see styles_device_defaults.xml. </style> <style name="Widget.CompoundButton.CheckBox"> <item name="android:background">@android:drawable/btn_check_label_background</item> <item name="android:button">?android:attr/listChoiceIndicatorMultiple</item> </style> <style name="Widget.CompoundButton.RadioButton"> <item name="android:background">@android:drawable/btn_radio_label_background</item> <item name="android:button">?android:attr/listChoiceIndicatorSingle</item> </style> <style name="Widget.CompoundButton.Star"> <item name="android:background">@android:drawable/btn_star_label_background</item> <item name="android:button">@android:drawable/btn_star</item> </style> Loading