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

时间:2019-03-16 21:43:41

标签: android androidx android-textinputlayout

你好,我正在使用androidx库创建一个应用程序,但是当我尝试添加一个开关来显示或隐藏带有app:endIconMode属性的TextInputEditText中的密码时,出现错误错误:找不到属性endIconMode。 / p>

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

我不确定我缺少什么,也许是依赖关系?据我在文档中阅读的内容,除了材料方面,不需要任何额外的依赖。

谢谢

2 个答案:

答案 0 :(得分:4)

按照Material Design Components release notes

  

1.1.0-alpha04

     
      
  • 添加对TextInputLayout的自定义结束图标的支持。 (5685941
  •   

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

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

答案 1 :(得分:0)

使用

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

或转到link