Как можно изменить цвет буквы?

311
15 марта 2017, 16:40

Можно ли поменять цвет некоторых букв в самом string.xml или программно, как это можно сделать?

<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>
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])

Программно:

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);
READ ALSO
Данные с 1С в html

Данные с 1С в html

Попробую вкратце описать мою ситуациюЯ пишу сайт для сотрудников компании

330
Новая овл карусель пропадает

Новая овл карусель пропадает

Есть 3 таких овл-каруселей на сайте, все они подключены через один script

404
Выдача сайта в поисковиках

Выдача сайта в поисковиках

Добрый деньСтолкнулся с такой проблемой

301
png белый фон html

png белый фон html

Убираю фон в картинке на прозрачныйсохраняю картинку в формате png, но при отображении на странице все равно в местах где фона не было появляется...

351