fahmy
fahmy

Reputation: 3672

Checked icon color in filter style Material Components Chip (Android)

I have the style for the Chip defined as below:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    ...
    <item name="chipStyle">@style/TagChip</item>
</style>

<style name="TagChip" parent="Widget.MaterialComponents.Chip.Filter">
    <item name="android:elevation">4dp</item>
    <item name="checkedIconTint">@color/white</item>
    <item name="chipBackgroundColor">@color/tag_chip_bg_color</item>
</style>

And this produces the following results:

enter image description here

I want to change the black checkmark icon to white.

I've tried changing the checkedIconTint property, but it doesn't change anything.

Upvotes: 1

Views: 1725

Answers (1)

Sowattana Sigen
Sowattana Sigen

Reputation: 202

You can set the checkedIcon programmatically like this

 chip.checkedIcon?.let {
        val wrappedDrawable =
            DrawableCompat.wrap(it)
        DrawableCompat.setTint(wrappedDrawable, Color.RED)
        chip.checkedIcon = wrappedDrawable
    }

Upvotes: 1

Related Questions