how to remove underline for textview in android

Sai Korlakunta picture Sai Korlakunta · Oct 29, 2016 · Viewed 20.4k times · Source

I have seen many questions regarding removing of underline for autolink of textview.

But for me, I am unable to remove underline for normal textview. I set the underline by:

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

Answer

Dany Y picture Dany Y · Apr 5, 2017

You can try

 textview.setPaintFlags(textview.getPaintFlags() & (~ Paint.UNDERLINE_TEXT_FLAG));

or more broadly just set,

textview.setPaintFlags(0) but the first option is more exact