Using attribute to modify a drawable element color

[亡魂溺海] 提交于 2019-12-03 01:29:10
eveliotc

Good news everyone! Starting Lollipop (21) you can use attributes to reference stuff like colors e.g. ?attr/colorPrimary.

Original answer:

As far I know you cannot reference style attributes from drawables, I couldn't find an usage like that in Android platform resources ($ANDROID_HOME/platforms/android-*/data/res/), all I see is that every drawable even for gradient drawables are defined in place or they just reference other drawables like color drawables.

Here is a related bug report for this (star it):

https://code.google.com/p/android/issues/detail?id=26251

You can workaround this by using separate xml drawables like explained at:

https://stackoverflow.com/a/13471695/172670

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!