为什么在 TextInputLayout 中找不到属性 app:endIconMode?

Why attribute app:endIconMode is not found in TextInputLayout?

你好,我正在使用 androidx 库创建一个应用程序,但是当我尝试添加一个切换以在具有 app:endIconMode 属性的 TextInputEditText 中显示或隐藏密码时,我收到错误错误:attribute endIconMode没有找到。

这是我的 TextInputLayout 和 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>

这些也是我在 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'

我不确定我错过了什么,也许是一种依赖?据我在文档中读到的,除了 material 之外不需要额外的依赖。

谢谢

根据 Material Design Components release notes:

1.1.0-alpha04

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

因此您必须至少将依赖项更改为 1.1.0-alpha04,而不是您正在使用的 1.0.0

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

使用

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

或转到link