Just set an attribute app:chipBackgroundColor
and pass a color state list to it:
<android.support.design.chip.Chip
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="true"
android:clickable="true"
android:focusable="true"
app:chipBackgroundColor="@color/bg_chip_state_list"
app:chipText="Test" />
bg_chip_state_list
looks like this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorSecondaryLight" android:state_checked="true" />
<item android:color="@color/colorPrimaryDark" />
</selector>
However I also had to set android:clickable
to true
to make this work
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…