Can I change the color of some letters in string.xml itself or programmatically, how can this be done?

 <string-array name="colors"> <item>I read the letter.</item> <item>It is only with the heart that one can see rightl.</item> <item>One can become a writer only if he is talented.</item> <item>They say, the winter will be cold.</item> </string-array> 

    1 answer 1

     <string-array name="colors"> <item> <![CDATA[ <font color="#005500">I</font> read the letter. ]]> </item> <item>It is only with the heart that one can see rightl.</item> <item>One can become a writer only if he is talented.</item> <item>They say, the winter will be cold.</item> </string-array> 

    Html.fromHtml(getResources().getStringArray(R.array.colors)[0])


    Programmatically:

     final SpannableStringBuilder text = new SpannableStringBuilder("Text"); final ForegroundColorSpan style = new ForegroundColorSpan(Color.rgb(255, 0, 0)); text.setSpan(style, 0, 1, Spannable.SPAN_INCLUSIVE_INCLUSIVE); textView.setText(text);