Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can underline words in TextView text

Is there possibility in android to provide TextView some text in Java code with setText(text) function with basic tags like and to make marked words underlined ?

like image 889
Damir Avatar asked Dec 19 '11 07:12

Damir


People also ask

How do you underline text in TextView?

You can also underline a portion of the text via code, it can be done by creating a SpannableString and then setting it as the TextView text property: SpannableString text = new SpannableString("Voglio sottolineare solo questa parola");text. setSpan(new UnderlineSpan(), 25, 6, 0);textView. setText(text);

How do you add a line in TextView?

If you just want to add a line break in the form: textView. setText(string1+System. getProperty ("line. separator")+string2); then it works a treat, thank you!

How do you set an underline for text?

The quickest way to underline text is to press Ctrl+U and start typing. When you want to stop underlining, press Ctrl+U again. You can also underline text and spaces in several other ways.


1 Answers

Yes, you can, use the Html.fromhtml() method:

textView.setText(Html.fromHtml("this is <u>underlined</u> text")); 
like image 104
kameny Avatar answered Oct 08 '22 15:10

kameny