Set the hover state to the same as focus state in RippleDrawable.

Bug 24810682

There was no hover state for bounded ripples and it was decided
that a solid background color exactly like the focus state
was desired. This change triggers the RippleDrawable to act as
if it is focused when it is hovered.

Change-Id: I94b2a4d03dd4c47fc021c84bb0ba4b4be82f3e95
This commit is contained in:
George Mount
2016-02-10 07:31:18 -08:00
parent 8585ed66b9
commit e4f976dc3b

View File

@@ -251,6 +251,7 @@ public class RippleDrawable extends LayerDrawable {
boolean enabled = false;
boolean pressed = false;
boolean focused = false;
boolean hovered = false;
for (int state : stateSet) {
if (state == R.attr.state_enabled) {
@@ -259,11 +260,13 @@ public class RippleDrawable extends LayerDrawable {
focused = true;
} else if (state == R.attr.state_pressed) {
pressed = true;
} else if (state == R.attr.state_hovered) {
hovered = true;
}
}
setRippleActive(enabled && pressed);
setBackgroundActive(focused || (enabled && pressed), focused);
setBackgroundActive(hovered || focused || (enabled && pressed), focused || hovered);
return changed;
}