I ran into a problem and I tried several ways to handle this, still unsuccessfully.
My application uses several themes, such as: Halloween, Chirstmas, etc., and I use some color attributes in widgets, such as TabLayout background, text color, etc., to contextualize the application.
Question: how to use the same color attributes with different values ​​depending on the context of the topic?
So, basically here are the usual ways to declare colors:
<color name="mapMarkerSelectedTextColor">@android:color/white</color> <color name="mapLoadingIndicatorColor">@color/white</color>
But the theme and colors are immutable, so I thought maybe I could override these colors within each theme, for example:
<item name="mapMarkerUnselectedTextColor">@color/christmas_red</item> <item name="mapMarkerSelectedTextColor">@color/white</item>
=> failed
Another declaration, declare these colors as attributes:
<attr name="mapLoadingIndicatorColor" format="reference|color" /> <attr name="map_autocomplete_accent_color" format="reference|color" />
And use the theme in my XML as follows: " ?attr/mapLoadingIndicatorColor ". But these features are only allowed from the Lollipop version and cause crashes before.
I read a lot about theme customization, color redefinition, but I have not found a clear solution to this situation.
Thank you anyway.