material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[Chip] background doesn't change color while being checked.

Open Gowsky opened this issue 7 years ago • 7 comments

ColorStateList set as background for Chip inside ChipGroup doesn't work. The background color used is always from unchecked state. The text color however gets updated upon state change.

Gowsky avatar Apr 05 '19 12:04 Gowsky

With the new update, the background colour is not getting changed when the chip is checked.

<com.google.android.material.chip.Chip android:id="@+id/general_feedback_chip_idea" style="@style/AppTheme.ChoiceChips" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checkable="true" android:clickable="true" android:focusable="true" android:text="Idea" app:chipStrokeColor="@color/colorPrimaryDark" app:chipStrokeWidth="1dp" />


<style name="AppTheme.ChoiceChips" parent="@style/Widget.MaterialComponents.Chip.Choice"> <item name="chipBackgroundColor">@color/feedback_chip_state_list</item> <item name="android:textColor">@color/feedback_chip_text_state_list</item> </style>


feedback_chip_state_list

<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@color/colorPrimaryDark" android:state_checked="true"/> <item android:color="@color/white" /> </selector>

image

Anjula avatar Apr 08 '19 06:04 Anjula

It works with state_selected though. Is this a bug or does a click on chip now select it instead of check it?

TadejZupancic avatar Apr 08 '19 12:04 TadejZupancic

https://github.com/material-components/material-components-android/commit/b544530ac0d9e1e1741de4f16ea77da13449fd92 added support for checked state in addition to selected state. Could you please try adding android:enabled="true" in your CSL on the state_checked line?

wcshi avatar Apr 08 '19 13:04 wcshi

Adding enabled does not work.

TadejZupancic avatar Apr 09 '19 06:04 TadejZupancic

Could you please share repo steps / code and file a bug at https://issuetracker.google.com/issues/new?component=439535

wcshi avatar Apr 09 '19 11:04 wcshi

Responded on bug. Closing issue, please comment on the public bug in the future, thanks!

wcshi avatar Apr 09 '19 20:04 wcshi