-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
The color of the text does not update when used with a ColorStateList:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="@color/gray_6"/>
<item android:state_selected="true" android:color="@color/gray_6"/>
<item android:state_focused="true" android:color="@color/gray_6"/>
<item android:color="@color/highlight_blue"/>
</selector>
textDrawable.setTextColor(getResources.getColorStateList(R.color.highlight_text));
This can be fixed by invalidating the view on state changed:
@Override
protected boolean onStateChange(int[] state) {
// Upon state changes, grab the correct text color
if (updateTextColors(state)) {
invalidateSelf();
return true;
}
return false;
}
I've tested this on 4.0.4, 4.4.2 and 6.0.1. Happy to send a PR if you'd like.
Metadata
Metadata
Assignees
Labels
No labels