How to change underline color error textinputlayout android

I would like to know how to change the error color of the TextInputLayout underline.

TextInputLayout with error

Upvotes: 0

Views: 1803

Answers (2)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363745

Just use the app:boxStrokeErrorColor attribute:

    <com.google.android.material.textfield.TextInputLayout
        app:boxStrokeErrorColor="@color/primaryLightColor"
        ...>

enter image description here

It requires Material Components lirabry version 1.2.0.

Upvotes: 4

The_Martian
The_Martian

Reputation: 3767

You can change the color in the edittext background as such. This background makes the underline to disappear. But you can make it to whatever color you want.

<android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/activity_horizontal_margin"
            app:hintEnabled="false">

            <android.support.design.widget.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Floating Hint Disabled"
                android:background="@android:color/transparent" />

        </android.support.design.widget.TextInputLayout

Upvotes: 1

Related Questions