Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove underline for textview in android

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);
like image 540
Sai Korlakunta Avatar asked Oct 29 '16 12:10

Sai Korlakunta


People also ask

How to remove underline on Android keyboard?

So, in Gboard settings - go to settings, language & input then note that Gboard has to be set as the spell checker for the system. So switch ON spell check to select Gboard, then switch off spell check in Gboard settings (and not system which remains on).

How to remove underline from keypad in mobile?

Originally Answered: How do I remove the underline feature while typing in Android keyboard ? Goto settings > Language & input > Android Keyboard settings > auto correction > off.

How do I get rid of the line on my keyboard?

On your keyboard, press and hold the left or right Shift key and then press the End key to highlight the entire line. Press the Delete key to delete the line of text.


Video Answer


3 Answers

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

like image 54
Dany Y Avatar answered Oct 11 '22 19:10

Dany Y


Here is technique you can try to remove underline from any textview or edit text using the given below example code snippet

<TextView
    android:id="@+id/et"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:layout_marginBottom="10dp"
    android:hint="This is first EditText"
    android:fontFamily="sans-serif-light"
    android:background="@null"
    />

Use of the attribute

android:background="@null"

you can remove underline from textview or edit text

You can also try putting transparent color to the background to remove underline beneath a textview.

like image 11
Ali Nawaz Avatar answered Oct 11 '22 19:10

Ali Nawaz


Maybe it's too late to answer this good question but I share my experience; perhaps it might be helpful for some one.

There is a really practical and easy way to remove underline for a text. And that is: textview.setPaintFlags(View.INVISIBLE);

It works perfect for me.

like image 2
Hossein Seifi Avatar answered Oct 11 '22 19:10

Hossein Seifi