Skip to content

Instantly share code, notes, and snippets.

@macieknajbar
Created June 13, 2020 18:50
Show Gist options
  • Save macieknajbar/7e21d24b5b3b96a3cfa63371f649567b to your computer and use it in GitHub Desktop.
Save macieknajbar/7e21d24b5b3b96a3cfa63371f649567b to your computer and use it in GitHub Desktop.
@Override
protected boolean onStateChange(int[] stateSet) {
final boolean changed = super.onStateChange(stateSet);
boolean enabled = false;
boolean pressed = false;
boolean focused = false;
boolean hovered = false;
for (int state : stateSet) {
if (state == R.attr.state_enabled) {
enabled = true;
} else if (state == R.attr.state_focused) {
focused = true;
} else if (state == R.attr.state_pressed) {
pressed = true;
} else if (state == R.attr.state_hovered) {
hovered = true;
}
}
setRippleActive(enabled && pressed);
setBackgroundActive(hovered, focused, pressed);
return changed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment