Why attribute app:endIconMode is not found in TextInputLayout?

acabezas picture acabezas · Mar 16, 2019 · Viewed 11.5k times · Source

Hello I am creating an app with the androidx libraries but when I am trying to add a toggle to show or hide the password in an TextInputEditText with the app:endIconMode attribute I am getting the error error: attribute endIconMode not found.

This is my TextInputLayout and TextInputEditText

<com.google.android.material.textfield.TextInputLayout
            android:id="@+id/password_text_input_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="password"
            app:endIconMode="password_toggle"
            app:layout_constraintTop_toBottomOf="@+id/user_text_input_layout"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">

        <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/password_text_input_edit_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"/>

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

Also these are my dependencies in gradle

implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'com.google.android.material:material:1.0.0'

I am not sure what i am missing, maybe a dependency? As far as i read in the documentation no extra dependency besides the material one is required.

Thanks

Answer

ianhanniballake picture ianhanniballake · Mar 16, 2019

As per the Material Design Components release notes:

1.1.0-alpha04

  • Adding support for a custom end icon for the TextInputLayout. (5685941)

Therefore you must change your dependency to at least 1.1.0-alpha04, not the 1.0.0 you are using:

implementation 'com.google.android.material:material:1.1.0-alpha04'