I have an application with different themes accessible. The color of a part of the text may vary depending on the theme. But when I use a color attribute that varies according to the theme, the color is not correct: the text is written in black instead of the desired color.
the set color with "font color="#307CA4""
is ok
but with font "color=?color_txt_red"
not work.
why?
Part of code used:
file string.xml :
<resources>
<string name="txt_show" formatted="false"><![CDATA[<font color="#307CA4" ><b>Liste des messages reçus : </b></font>Vous avez <font color=?color_txt_red>%d message </font>non lu]]></string>
</resources>
file color.xml :
<resources>
<color name="red_1">#ff0000</color>
<color name="red_2">#c3051f</color>
</resources>
file style.xml :
<attr name="color_txt_red" format="reference|color" />
<style name="theme_1" >
<item name="color_txt_red">@color/red_1</item>
</style>
<style name="theme_2" >
<item name="color_txt_red">@color/red_2</item>
</style>
part of file testMain.java:
int nbMessage = 0;
tv.setText(Html.fromHtml(getString(R.string.txt_show, nbMessage)));
image valid
image error
May anyone could help me, please? Thank you!