I want to show a string for ex "RedBlueGray" in a single text view like Red should appear with red font color, Blue with blue font and Gray with Gray font.Is it possible? if so, What is the best way to achieve. Note the string I want to display will change dynamically but not colors.
Asked
Active
Viewed 3,500 times
3 Answers
1
Simplest way to do this define a html string:
String text="<FONT COLOR="#RED">red</FONT><FONT COLOR="#GREEN">green</FONT><FONT COLOR="#BLUE">blue/FONT>";
set this string to textView by
TextView.setText(Html.fromHtml(text));

jeet
- 29,001
- 6
- 52
- 53
0
See SpannedString & SpannedStringBuilder & ColorSpan
http://developer.android.com/reference/android/text/style/ForegroundColorSpan.html
http://developer.android.com/reference/android/text/SpannedString.html

Roman Black
- 3,501
- 1
- 22
- 31