I was wondering if its possible to have private color resources in android?
Eg: Files in main: colors.xml:
<color name="red">#520A2A</color>
<color name="red_darken_1">#A11453</color>
Files in flavor 1: element_colors.xml:
<color name="header_color">@colors/red</color>
<color name="footer_color">@color/red_darken_1</color>
Files in flavor 2: colors.xml:
<color name="blue">#041B3F</color>
<color name="blue_darken_1">#244B77</color>
element_colors.xml:
<color name="header_color">@colors/blue</color>
<color name="footer_color">@color/blue_darken_1</color>
Now I don't want people to use colors in layout files or styles from colors.xml, but I always want them to use it from element_colors.xml so that the app does not become specific to a single flavor. Basically, how to make some color files inaccessible to layouts and styles?
Yes, you can make resources private for a library.
Please have look at the Documentation.
and specifically, note the trick,
All resources in a library default to public. To make all resources implicitly private, you must define at least one specific attribute as public.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With