我以编程方式芯片(材料组件),使用setChipBackgroundColor
更改芯片状态按下颜色,但它有两种按下颜色效果,我想删除默认按下灰色
- 我的定制印刷机(#daecff)
- 默认按下颜色(灰色)
谢谢
https://i.imgur.com/5z94oUA.jpg
Chip chip = new Chip(context);
chip.setText(name);
chip.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
chip.setTextColor(ContextCompat.getColor(context, R.color.chip_color));
chip.setOnClickListener(onClickListener);
chip.setChipStrokeColorResource(R.color.chip_color);
chip.setChipStrokeWidth(5);
chip.setChipBackgroundColor(
ContextCompat.getColorStateList(context, R.color.bg_chip)
);
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#daecff"/>
<item android:color="@color/white"/>
</selector>