简体   繁体   English

如何更改API <21上的图标颜色?

[英]How change icons color on API < 21?

Because API 19 (KitKat) is still very popular, it's a good choice to support this release. 因为API 19(KitKat)仍然很受欢迎,所以它是支持此版本的一个不错的选择。 However, it does not support many features, such as backgroundTint and ImageTint. 但是,它不支持许多功能,例如backgroundTint和ImageTint。 This puts me in various compatibility issues and design choices. 这使我面临各种兼容性问题和设计选择。

I have several icons to load on a screen and I'm currently using setImageTintList to make the app dynamic. 我有几个图标要加载到屏幕上,并且当前正在使用setImageTintList来使应用程序动态化。

The "faces" and "bucks" should change color according to the element in a recyclerView. “面”和“块”应根据recyclerView中的元素更改颜色。 What is the best way to support this function on systems with API <21? 在API <21的系统上支持此功能的最佳方法是什么?

I'm not sure what APIs you exactly mean by saying "backgroundTint and ImageTint", but there's a compatibility ViewCompat class which will backport some functionality up to API 4. 我不确定说“ backgroundTint和ImageTint”到底是什么API,但是有一个兼容的ViewCompat类可以将某些功能支持到API 4。

Amongst them are: 其中包括:

If by saying "ImageTint" you meant android:tint or setImageTintList() , then this answers your question. 如果说“ ImageTint”是指android:tintsetImageTintList() ,那么这将回答您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM