1

I'm creating a password field with custom background using TextInputLayout and AppCompatEditText. Before using Theme.MaterialComponents the the field was fine, but after using it, my AppCompatEditText start showing a line highlight at the bottom. I'm sure it is because of Material styling, but I couldn't figure out which attribute I can use to remove the line and I also not really sure whether it is on the TextInputLayout or the AppCompatEditText.

EditText with bottom highlight

<com.google.android.material.textfield.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            app:hintEnabled="false"
            app:passwordToggleEnabled="true">

            <androidx.appcompat.widget.AppCompatEditText
                android:id="@+id/passwordInput"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/activity_horizontal_margin"
                android:layout_marginTop="6dp"
                android:layout_marginEnd="@dimen/activity_horizontal_margin"
                android:background="@drawable/bg_input_border"
                android:fontFamily="@font/opensans_regular"
                android:hint="@string/password_hint"
                android:inputType="textPassword"
                android:paddingLeft="10dp"
                android:paddingTop="13dp"
                android:paddingRight="10dp"
                android:paddingBottom="13dp"
                android:textSize="16sp" />
        </com.google.android.material.textfield.TextInputLayout>
Edric
  • 24,639
  • 13
  • 81
  • 91
Bagus Aji Santoso
  • 507
  • 1
  • 7
  • 16
  • You should use the `com.google.android.material.textfield.TextInputEditText` instead of `androidx.appcompat.widget.AppCompatEditText`. Currently **you can't hide** the underline, you can only change the color of the **stroke**. Check this [answer](https://stackoverflow.com/a/57985955/2016562). However you can use the **`Widget.MaterialComponents.TextInputLayout.OutlinedBox` style** in the `TextInputLayout` and **remove** the `android:background="@drawable/bg_input_border"`. – Gabriele Mariotti Feb 27 '20 at 14:30
  • @GabrieleMariotti I've used `OutlinedBox` style and it's great, but the focused `EditText` still have the stroke. Is it also unhideable? – Bagus Aji Santoso Feb 28 '20 at 06:04
  • Also in this case you can use the boxStrokeColor. It is a selector, and you can use the same color when it is focused. Check this [answer](https://stackoverflow.com/questions/56292017/textinputlayout-box-color/57884207#57884207) – Gabriele Mariotti Feb 28 '20 at 08:31

1 Answers1

0

You can set boxStrokeWidth value

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

or Programmatically

textInputLayout.setBoxStrokeWidth(0);