Rectangle 27 0

Set underline text to TextView in android programmatically?


textview.setPaintFlags(textview.getPaintFlags()| Paint.UNDERLINE_TEXT_FLAG);

what about remove underline?

Note
Rectangle 27 0

Set underline text to TextView in android programmatically?


TextView theTextView = new TextView(this);

theTextView.setText(Html.fromHtml("<u>Text to underline</u>"));

Here is the simplest way

Note
Rectangle 27 0

Set underline text to TextView in android programmatically?


i don't know if somebody is still interested in this topic, but i disovered that textview.setTypeface(Typeface.NORMAL); did not work for me. My solution was this snippet textView.setPaintFlags(0);

Note
Rectangle 27 0

Set underline text to TextView in android programmatically?


TextView myTextView = new TextView(this);
SpannableString mySpannableString = new SpannableString("My String");
mySpannableString.setSpan(new UnderlineSpan(), 0, mySpannableString.length(), 0);
myTextView.setText(mySpannableString);
Note
Rectangle 27 0

Set underline text to TextView in android programmatically?


TextView myTextView = new TextView(this);
SpannableString mySpannableString = new SpannableString("My String");
mySpannableString.setSpan(new UnderlineSpan(), 0, mySpannableString.length(), 0);
myTextView.setText(mySpannableString);
Note
Rectangle 27 0

Set underline text to TextView in android programmatically?


TextView theTextView = new TextView(this);

theTextView.setText(Html.fromHtml("<u>Text to underline</u>"));

Here is the simplest way

Note
Rectangle 27 0

Set underline text to TextView in android programmatically?


textview.setPaintFlags(textview.getPaintFlags()| Paint.UNDERLINE_TEXT_FLAG);

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

what about remove underline?

Note