There is the following code:
String s = message + "\n" + date;
Spannable f = Spannable.Factory.getInstance().newSpannable(s);
f.setSpan(new ForegroundColorSpan(Color.BLUE), 0, message.length(), 0);
f.setSpan(new ForegroundColorSpan(Color.RED), message.length() + 1, s.length(), 0);
textView.setText(f);
This code works fine for setting up diffent colors for textView. But I need another feature - I'd like that "date" has got smaller size of font and italic typeface. How can I achieve that?
You can make use of Html.fromHtml("your html string"), to do any style you want in HTML and then show it in the textview as shown below:
And the XML string.xml, must have the string declared as shown below:
Hope this helps.
Regards!
You can use HTML tags, like this:
Yes, that is absolutely possible. You can simply add another Span:
In this case, its a
StyleSpan
to Italic and aRelativeSizeSpan
.Check this
Different font size of strings in the same TextView
Try the below
For more styling
http://www.chrisumbel.com/article/android_textview_rich_text_spannablestring