diff options
| author | Alan Viverette <alanv@google.com> | 2014-04-22 19:07:06 -0700 |
|---|---|---|
| committer | Alan Viverette <alanv@google.com> | 2014-04-22 19:07:06 -0700 |
| commit | 61956606818918194a38e045a8e35e7108480e5e (patch) | |
| tree | 328d1ebf6485b410f19d0b5263712bead1f8630d /core/java/android/widget/CompoundButton.java | |
| parent | b78263d37690a6a5cb12dd31d82ad2e140b3dfc7 (diff) | |
Add ripple to switches, radio buttons, check boxes, seek bars
BUG: 14231772
Change-Id: Ie40eac9f68815294460175965a999dd75f4144b5
Diffstat (limited to 'core/java/android/widget/CompoundButton.java')
| -rw-r--r-- | core/java/android/widget/CompoundButton.java | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java index 42985457c7fa..ddc8b050af18 100644 --- a/core/java/android/widget/CompoundButton.java +++ b/core/java/android/widget/CompoundButton.java @@ -261,15 +261,13 @@ public abstract class CompoundButton extends Button implements Checkable { @Override protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - final Drawable buttonDrawable = mButtonDrawable; if (buttonDrawable != null) { final int verticalGravity = getGravity() & Gravity.VERTICAL_GRAVITY_MASK; final int drawableHeight = buttonDrawable.getIntrinsicHeight(); final int drawableWidth = buttonDrawable.getIntrinsicWidth(); - int top = 0; + final int top; switch (verticalGravity) { case Gravity.BOTTOM: top = getHeight() - drawableHeight; @@ -277,12 +275,24 @@ public abstract class CompoundButton extends Button implements Checkable { case Gravity.CENTER_VERTICAL: top = (getHeight() - drawableHeight) / 2; break; + default: + top = 0; } - int bottom = top + drawableHeight; - int left = isLayoutRtl() ? getWidth() - drawableWidth : 0; - int right = isLayoutRtl() ? getWidth() : drawableWidth; + final int bottom = top + drawableHeight; + final int left = isLayoutRtl() ? getWidth() - drawableWidth : 0; + final int right = isLayoutRtl() ? getWidth() : drawableWidth; buttonDrawable.setBounds(left, top, right, bottom); + + final Drawable background = getBackground(); + if (background.supportsHotspots()) { + background.setHotspotBounds(left, top, right, bottom); + } + } + + super.onDraw(canvas); + + if (buttonDrawable != null) { buttonDrawable.draw(canvas); } } |
