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 EditTe
Set background to null
android:background="@null" in your xml
if you are using background then you must use this tag
android:testCursorDrawable="@null"
android:background="@android:color/transparent"
Or
android:background="@null"
Simply Use This
editText.setBackgroundColor(Color.TRANSPARENT);
If you are using the EditText inside TextInputLayout use app:boxBackgroundMode="none"
as following:
<com.google.android.material.textfield.TextInputLayout
app:boxBackgroundMode="none"
...
>
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.google.android.material.textfield.TextInputLayout>
You can also define a STYLE for your editText so you can regroup all properties in common. It is very powerful if you have to multiple edit text that need to has the behaviour
Put the code in res/values/styles.xml
<style name="MyEditTextStyle" parent="@android:style/TextAppearance.Widget.EditText"> <item name="android:background">@color/transparence</item> //NO UNDERBAR <item name="android:maxLines">1</item> <item name="android:height">28dp</item> //COMMON HEIGHT </style>
After that you just need to call it in your editText
<EditText
android:id="@+id/edit1"
style="@style/MyEditTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/edit2"
style="@style/MyEditTextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />