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

[MaterialToolbar] Cannot clear the navigation icon tint #2678

Closed
Back4fire opened this issue May 2, 2022 · 2 comments
Closed

[MaterialToolbar] Cannot clear the navigation icon tint #2678

Back4fire opened this issue May 2, 2022 · 2 comments

Comments

@Back4fire
Copy link

I can use MaterialToolbar. setNavigationIconTint(@ColorInt int navigationIconTint) to set the tint of the navigation icon. But it seems that there is no way to clear it. After looking through the source code, I think it will resolve the issue that simply changing the type of the parameter "navigationIconTint" from "int" to "Integer".

@Back4fire Back4fire added the bug label May 2, 2022
@dsn5ft dsn5ft self-assigned this May 2, 2022
@dsn5ft
Copy link
Contributor

dsn5ft commented Jun 2, 2022

Hi @Back4fire, I started looking into this but the tricky thing is that DrawableCompat#setTint takes in an int.

However, there is a DrawableCompat#setTintList method which takes a nullable ColorStateList. I tried using that and it seems to work; however, a key detail is that it will also clear any tint like android:tint="?attr/colorControlNormal" in the vector drawable xml, meaning the navigation icon drawable will take on the color of the android:fillColor.

So basically I can add a materialToolbar.clearNavigationIconTint() method to do the above, but I'm not sure how useful it will be.

What's your exact use case? Why do you have to set a tint and then clear it?

@Back4fire
Copy link
Author

Hi, @dsn5ft, sorry for not replying in time. In my project, there is an activity that loading data from the server continuously. If the data is abnormal, the navigation icon ( and some other elements in UI ) will be changed to a special color to alert the user. If the data is normal, the navigation icon should be changed back to the normal color.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants