Set underline text to TextView in android programmatically

Solution 1:

Try this code:

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

Solution 2:

Here is the simplest way

TextView theTextView = new TextView(this);

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