Using attribute to modify a drawable element color

前端 未结 1 1066
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-05 06:27

I try to make a custom Drawable by using attribute but I have an inflating error

01-21 11:01:06.171: E/AndroidRuntime(13695): Caused by: android.con         


        
1条回答
  •  别那么骄傲
    2021-02-05 07:07

    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

    0 讨论(0)
提交回复
热议问题