Hey guys =) android newbie here. I'm trying to write a sentence in TextView, and I only want one word in the sentence to be in italics. for e.g. android:text="my name isn't Amber?" ==> I want only the word "isn't" to be italicised. Any help would be appreciated. TIA!
TextView: How to italicise one word in a sentence
187 Views Asked by Amber Katz At
2
There are 2 best solutions below
0

One way to achieve that is using a Spannable, A StyleSpan
with Typeface.ITALIC
on isn't
, in your case, and then setting the resulting CharSequence
to the TextView
. Another way is to use an Html
string, enclosing isn't
between <i></i>
, and formatting it with Html.fromHtml
You can use the plain old html tags. This should do the trick: