4

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?

David Medenjak
  • 33,993
  • 14
  • 106
  • 134
Alexei
  • 14,350
  • 37
  • 121
  • 240

1 Answers1

3

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.

David Medenjak
  • 33,993
  • 14
  • 106
  • 134