Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chip] Setting current drawable state for updated icons #2118

Closed
ViHtarb opened this issue Mar 9, 2021 · 2 comments
Closed

[Chip] Setting current drawable state for updated icons #2118

ViHtarb opened this issue Mar 9, 2021 · 2 comments
Assignees
Labels

Comments

@ViHtarb
Copy link

ViHtarb commented Mar 9, 2021

Description: When chipIcon updates and that icon is not stateful the current state of the view(checked etc) is ignored but chip can have chipIconTint and in result we can have icon without actual tint state

Expected behavior:
before icon update
before icon update
after icon update
after icon update

Source code:
ChipStyle

<style name="Widget.Chip.Choice" parent="Widget.MaterialComponents.Chip.Choice">
        <item name="chipIconVisible">true</item>
        <item name="chipIconTint">@color/choice_chip_icon_tint</item>
</style>

choice_chip_icon_tint

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="?colorOnPrimary" android:state_enabled="true" android:state_selected="true"/>
    <item android:color="?colorOnPrimary" android:state_enabled="true" android:state_checked="true"/>
    <item android:color="?colorPrimary" android:state_enabled="true"/>
    <item android:alpha="0.35" android:color="?colorOnSurface"/>
</selector>

Chip in layout

<com.google.android.material.chip.Chip
      android:id="@+id/choice"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Choice"
      app:chipIcon="@drawable/abc_vector_test"/>

And simply need change icon in code

Material Library version: 1.4.0-alpha01 and less

@ViHtarb ViHtarb added the bug label Mar 9, 2021
@floblaf
Copy link

floblaf commented Mar 30, 2021

I did encountered the same issue
As I'm in a recycler view, I first thought I had issue recycling my view. But even if I set again all property to be sure (icon, tint, size), it's still broken

The only ugly solution I found is to run those lines, just after changing the icon :
isChipIconVisible = false
isChipIconVisible = true

@debugmoov
Copy link

happens to me too. the above solution doesn't work for me, what does is resetting the chip icon tint
chip.chipIconTint = null
chipIconTint = AppCompatResource.getColorStateList(context, colorResId)

@drchen drchen self-assigned this Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants