Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide underbar in EditText

How can I hide the EditText underbar (the prompt line with little serifs at the ends)?

There might be a better way to do what I want: I have a layout with an EditText. Normally, this displays fine where the user can tap on it and begin entering or editing text.

Sometimes, however, I would like to use the same layout (simplifies other logic) to display the same data in a read-only manner. I want the presentation to be similar - it should have the same height and same font, but not have the underbar.

As a stop-gap measure, I'm going to implement this by removing the EditText and substituting a TextView. I think that will give the desired results, but it seems like a roundabout an expensive way to do something that ought to be easy to do by changing attributes.

like image 765
Peri Hartman Avatar asked Dec 20 '12 15:12

Peri Hartman


People also ask

How to hide EditText bottom line?

Start with the 9-patch that is used for normal EditText fields. Modify it to strip out the underbar and other graphics you don't want. With this, your modified EditText will have the same margins and overall appearance as normal EditText fields. If you simply set the background to null, it will lose the margins.


1 Answers

You can set the EditText to have a custom transparent drawable or just use

android:background="@android:color/transparent" 

or

android:background="@null" 

or Programmatically

editText.setBackgroundResource(android.R.color.transparent); 
like image 114
ha1ogen Avatar answered Oct 19 '22 19:10

ha1ogen