How can remove underline from TextInputLayout or TextInputEditText

Viewed 442

I want remove underline.

Picture showing an underline on Android

This is my code:

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/textInputLayoutName"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="60dp"
    android:layout_marginStart="5dp"
    android:layout_marginEnd="5dp"
    app:boxCornerRadiusTopStart="20dp"
    app:boxCornerRadiusTopEnd="20dp"
    app:boxCornerRadiusBottomEnd="20dp"
    app:boxCornerRadiusBottomStart="20dp"
    >

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/textInputEditTextName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/register_hint_name"
        android:inputType="text"
        android:textColor="@color/black" />

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

set background like this:

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

or

android:background="@null"

you can also see this answer

just add android:background="" inside TextInputEditText

You can also create a layout file for the background you wish and set it as: android:background="@layout/nameoffile"

You can set below attributes in TextInputLayout to have no width

app:boxStrokeWidth="0dp"
app:boxStrokeWidthFocused="0dp"

Your layout

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/textInputLayoutName"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="60dp"
    android:layout_marginStart="5dp"
    android:layout_marginEnd="5dp"
    app:boxCornerRadiusTopStart="20dp"
    app:boxCornerRadiusTopEnd="20dp"
    app:boxStrokeWidth="0dp"
    app:boxStrokeWidthFocused="0dp"
    app:boxCornerRadiusBottomEnd="20dp"
    app:boxCornerRadiusBottomStart="20dp">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/textInputEditTextName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/register_hint_name"
        android:inputType="text"
        android:textColor="@color/black" />

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

Preview

enter image description here

Related