30

I need to remove the bottom line of TextInputEditText I set background to transparent and null but nothing is working.

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/bg_textinput_layout"
    android:hint="@string/app_name">

    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/transparent"/>

</com.google.android.material.textfield.TextInputLayout>

The bg_textinput_layout

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android">

<solid android:color="@color/white"/>

<stroke android:width="@dimen/spacing_1"
    android:color="@color/hint_text_color"/>
</shape>
pkaeding
  • 36,513
  • 30
  • 103
  • 141
Balaji
  • 1,773
  • 1
  • 17
  • 30
  • You don't need this bg_textinput_layout background. Just use boxBackgroundColor to have a white box. – Gabriele Mariotti Sep 24 '19 at 11:46
  • 2
    I applied this style Widget.MaterialComponents.TextInputLayout.OutlinedBox to textinputlayout and now it is working – Balaji Sep 25 '19 at 05:09
  • 1
    Here is the simple solution https://stackoverflow.com/questions/57063519/remove-underline-from-textinputedittext/63308187#63308187 – Anshad Ali KM Aug 07 '20 at 19:40

2 Answers2

66

You can apply app:boxStrokeWidth="0dp" and app:boxStrokeWidthFocused="0dp" (or theapp:boxStrokeColor attribute using a selector with the same values of the boxBackgroundColor).

   <com.google.android.material.textfield.TextInputLayout
       app:boxStrokeWidth="0dp"
       app:boxStrokeWidthFocused="0dp"
       ...>

enter code here

For a white box without background and border:

<com.google.android.material.textfield.TextInputLayout
    app:boxStrokeWidth="0dp"
    app:boxStrokeWidthFocused="0dp"
    app:boxStrokeColor="#FFF"
    app:boxBackgroundColor="#FFF"
    ...>

enter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
2

in the TextInputLayout, set app:boxStrokeWidth="0dp" in the TextInputEditText, set app:boxBackgroundColor="@color/white" . it worked for me when my background is white.

beokh
  • 191
  • 2
  • 3