27

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

acabezas
  • 731
  • 1
  • 7
  • 20
  • 2
    this should work as per the older version, no need to import alpha app:passwordToggleEnabled="true" – Roman Gherta May 14 '19 at 20:20
  • 1
    @RomanGherta this should be the answer honestly. Worked awesomely for me without having to import anything new – Vucko Dec 26 '19 at 14:21

2 Answers2

38

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'
Community
  • 1
  • 1
ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • 2
    I know I'm late to the party, but support for the `app:endIconMode` attribute was actually introduced in this commit: https://github.com/material-components/material-components-android/commit/4c2e9c40040d1aa151f0534b21e3045dc2ccb788 – Edric May 04 '19 at 16:14
0

use

implementation 'com.google.android.material:material:1.3.0-alpha01'

or goto link