Search code examples
androidtextviewtext-styling

How to set the font style to bold, italic and underlined in an Android TextView?


I want to make a TextView's content bold, italic and underlined. I tried the following code and it works, but doesn't underline.

<Textview android:textStyle="bold|italic" ..

How do I do it? Any quick ideas?


Solution

  • I don't know about underline, but for bold and italic there is "bolditalic". There is no mention of underline here: http://developer.android.com/reference/android/widget/TextView.html#attr_android:textStyle

    Mind you that to use the mentioned bolditalic you need to, and I quote from that page

    Must be one or more (separated by '|') of the following constant values.

    so you'd use bold|italic

    You could check this question for underline: Can I underline text in an android layout?