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/Switch.java | |
parent | b78263d37690a6a5cb12dd31d82ad2e140b3dfc7 (diff) | |
download | frameworks_base-61956606818918194a38e045a8e35e7108480e5e.zip frameworks_base-61956606818918194a38e045a8e35e7108480e5e.tar.gz frameworks_base-61956606818918194a38e045a8e35e7108480e5e.tar.bz2 |
Add ripple to switches, radio buttons, check boxes, seek bars
BUG: 14231772
Change-Id: Ie40eac9f68815294460175965a999dd75f4144b5
Diffstat (limited to 'core/java/android/widget/Switch.java')
-rw-r--r-- | core/java/android/widget/Switch.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java index 3d23e4d..d013e7b 100644 --- a/core/java/android/widget/Switch.java +++ b/core/java/android/widget/Switch.java @@ -773,8 +773,6 @@ public class Switch extends CompoundButton { @Override protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - final Rect tempRect = mTempRect; final Drawable trackDrawable = mTrackDrawable; final Drawable thumbDrawable = mThumbDrawable; @@ -785,16 +783,12 @@ public class Switch extends CompoundButton { final int switchRight = mSwitchRight; final int switchBottom = mSwitchBottom; trackDrawable.setBounds(switchLeft, switchTop, switchRight, switchBottom); - trackDrawable.draw(canvas); - - final int saveCount = canvas.save(); - trackDrawable.getPadding(tempRect); + final int switchInnerLeft = switchLeft + tempRect.left; final int switchInnerTop = switchTop + tempRect.top; final int switchInnerRight = switchRight - tempRect.right; final int switchInnerBottom = switchBottom - tempRect.bottom; - canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom); // Relies on mTempRect, MUST be called first! final int thumbPos = getThumbOffset(); @@ -803,6 +797,18 @@ public class Switch extends CompoundButton { int thumbLeft = switchInnerLeft - tempRect.left + thumbPos; int thumbRight = switchInnerLeft + thumbPos + mThumbWidth + tempRect.right; thumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom); + + final Drawable background = getBackground(); + if (background.supportsHotspots()) { + background.setHotspotBounds(thumbLeft, switchTop, thumbRight, switchBottom); + } + + super.onDraw(canvas); + + trackDrawable.draw(canvas); + + final int saveCount = canvas.save(); + canvas.clipRect(switchInnerLeft, switchTop, switchInnerRight, switchBottom); thumbDrawable.draw(canvas); final int drawableState[] = getDrawableState(); |