question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Chip] Unable to set chip text color

See original GitHub issue

Description: Full description of issue here I am using chip group and setting a style to customize colors:

    <style name="Colors_Widget.MaterialComponents.Chip.Choice" parent="Widget.MaterialComponents.Chip.Choice">
        <item name="chipBackgroundColor">@color/button_disposition_bg</item>
        <item name="chipStrokeWidth">1dp</item>
        <item name="android:textColor">@color/button_disposition_text</item>
        <item name="shapeAppearance">@drawable/button_disposition_shape</item>
    </style>

I faced with the problem - when my Chip is selected, background color is set properly, but I do not see the text. My text color selector:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/colorPrimary" android:state_enabled="true" />
    <item android:color="@color/colorMain" android:state_selected="false"/>
    <item android:color="@color/colorPrimary" android:state_checked="true" />
    <item android:color="@color/colorMain" android:state_checked="false"/>
    <item android:color="@color/colorPrimary" android:state_selected="true" />
</selector>

My background selector

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/colorMain" android:state_selected="true" />
    <item android:color="@color/colorPrimary" android:state_enabled="true" />
</selector>

Expected behavior: Screenshots and/or description of expected behavior When Chip is checked, the textColor = “@color/colorPrimary” , chipBackground = “@color/colorMain” <item android:color="@color/colorMain" android:state_selected="true" />…

But the chip is completely painted over with the background color so I do not see the text on it. Chip text color and background color are the same = “@color/colorMainSource code: The code snippet which is causing this issue. Please consider attaching a minimal sample app that reproduces the issue.

Android API version: Android API version here 29 Material Library version: Material Android Library version you are using here (e.g., 1.1.0-alpha07) 1.3.0-alpha01 Device: Device on which the bug was encountered here All devices To help us triage faster, please check to make sure you are using the latest version of the library.

We also happily accept pull requests.

Thank you in advance

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
KseniaKrasotinacommented, Jul 15, 2020

I have tried this way. It does not work for me. Chip becoming fully painted and text disappearing…For one moment I see the proper color, but text id disappearing fast…

0reactions
drchencommented, Oct 4, 2021

I’ll close the issue due to no further info available. Feel free to reopen it if it’s still reproducible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot add text color state list to Material Chip - Stack Overflow
It explains why your Chip is not checkable. The method chip.setTextColor is correct and works with a selector (but use the selector as...
Read more >
Chip - Android Developers
If false, the chip acts like a button. android:text - Sets the text of the chip. ... Returns the tint color for this...
Read more >
Chips | Angular Material
By default, chips use the primary color. Specify the color property to change the color to accent or warn . link Interaction Patterns....
Read more >
Android Chips — Material Component For Android - Medium
textColor — customize the text color. chipIconTint — the color of the Chip icons can be customized closeIconTint — Color of the close...
Read more >
Insert smart chips in your Google Sheets
Color; Size; Font style. To remove format changes, click Clear formatting. To remove a people chip and revert the cell to an email...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found