Does Android EditText has input type with clear button?

There is no internal input-type, but you can customize it to work so. This link might help you: Stack-Overflow: EditText with clear button


You can use the following, it works quite well

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.textfield.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/textInputLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:endIconMode="clear_text"
    tools:hint="Label">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/textInputEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:text="Value" />

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

But this approach would not be valid for a MaterialAutoCompleteTextView


If you're using TextInputLayout that you can use endIconMode and endIconDrawable

Tags:

Android