Skip to content Skip to sidebar Skip to footer

Remove Underline From Textinputedittext

I have an android screen which takes email from the user. Below is the snippet of the code, I want to remove the underline which appears below the text.

Solution 1:

If you want to use the filled box then below code perfectly work for me.

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

add above lines in the input layout.

Solution 2:

It looks like the Material Components library draws its own underline using app:boxStrokeColor. This attribute is a ColorStateList, so you have to create a color state list resource in which all states' colors are set to transparent. So basically you want to create a new file res/color/filename.xml:

<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:color="@android:color/transparent"android:state_pressed="true"android:state_focused="true"android:state_selected="true"android:state_checkable="true"android:state_checked="true"android:state_enabled="true"android:state_window_focused="true" /></selector>

and set the app:boxStrokeColor attribute to @color/filename.

However, this left me with a black underline which still doesn't respond to android:background=@null or <item name="colorControl*">@android:color/transparent</item>.


TL;DR

Quickfix: if you set the TextInputLayout outlined using style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox", the box looks almost the same, but the underline is gone. In order to remove the stroke just set the app:boxStrokeColor attribute to @null.

Solution 3:

app:boxBackgroundMode="none" in parent TextInputLayout

Solution 4:

<stylename="Theme.MyApp"parent="Theme.MaterialComponents.Light.NoActionBar"><itemname="textInputStyle">@style/Widget.MyApp.TextInputLayout</item></style><stylename="Widget.MyApp.TextInputLayout"parent="Widget.MaterialComponents.TextInputLayout.FilledBox"><itemname="boxStrokeWidth">0dp</item><itemname="boxStrokeWidthFocused">0dp</item></style>

Solution 5:

Setting the background of the TextInputLayout to a drawable and the one of the TextInputEditText to transparent removes the underline:

<com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:hint="@string/email"
        android:background="@drawable/blue_drawable"
        app:endIconMode="clear_text"
        app:endIconTint="@color/black"
        app:hintTextColor="@color/black">

    <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/black"
            android:background="@android:color/transparent"
            android:textSize="18sp"
            android:layout_margin="8dp" />

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

blue_drawable.xml

<shapexmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><cornersandroid:radius="20dp"/><solidandroid:color="@android:color/holo_blue_bright"/></shape>

enter image description here

Post a Comment for "Remove Underline From Textinputedittext"