Remove bottom line from TextInputEditText
Asked Answered
S

2

32

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>
Stoddart answered 24/9, 2019 at 11:19 Comment(3)
You don't need this bg_textinput_layout background. Just use boxBackgroundColor to have a white box.Ansel
I applied this style Widget.MaterialComponents.TextInputLayout.OutlinedBox to textinputlayout and now it is workingStoddart
Here is the simple solution #57064019Nuli
A
69

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

Ansel answered 24/9, 2019 at 11:44 Comment(1)
Why we can not hide the bottom line with FilledBox?Wunderlich
C
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.

Compromise answered 10/7, 2022 at 10:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.