My strings.xml contains the following string resource
<string name="contacts"><font fgcolor="#FF00FFFF">+</font> Contacts</string>
It is working fine and sets the textcolor to #FF00FFFF
But if I try to reference a color
<string name="contacts"><font fgcolor="@color/strings_font_fgcolor_cyan">+</font> Contacts</string>
it does not work.
I have added the color
<color name="strings_font_fgcolor_cyan">#FF00FFFF</color>
How I can reference this color from my string resource?
You can't reference a color resource value from within your strings. You will have to keep using fgcolor="#FF00FFFF"
or format your text at runtime.
Everything between <string name="contacts">
and </string>
is treated as your text and it is not processed any further.
If you want to use your resource color, you will have to do this at runtime, by parsing / replacing parts in your String with the loaded value, or manually adding the right tags to it.
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