Android: how to use the current theme's colors in a drawable xml? -


i have defined 2 themes different primary, primary dark, primary light , accent colors.

<style name="apptheme" parent="theme.appcompat.light.noactionbar">     <item name="colorprimary">@color/primary</item>     <item name="colorprimarydark">@color/primary_dark</item>     <item name="coloraccent">@color/accent</item> </style>  <style name="apptheme2" parent="apptheme">     <item name="colorprimary">@color/primary_2</item>     <item name="colorprimarydark">@color/primary_dark_2</item>     <item name="coloraccent">@color/accent_2</item> </style> 

apptheme default <application/> set apptheme2 in specific activities.

in drawable file xml i'm using same primary colors of apptheme defined in colors.xml

the drawable used in many activities both themes, when there apptheme2 see different colors. there way make drawable use colors of current theme current activity?

you can use attribute color used theme:

android:color="?colorprimary" 

this possible in android 5.0 or higher.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -