Set underline text to TextView in android programmatically

Pratik Patel picture Pratik Patel · Oct 20, 2012 · Viewed 34.2k times · Source

I want to know how to set underline text to TextView in android? Please make a note that I don't have capability to set a strings.xml with pre-populated strings is there any way to add it with pure java code in Android.

Answer

yahya.can picture yahya.can · Oct 20, 2012

Try this code:

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