当 EditText 的输入类型为密码时,Android 回话宣布 TextInputLayout 的内容描述不正确

问题描述

我的 Android 应用中有一个具有以下结构的 TextInputLayout。

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:imeOptions="actionDone"
        android:id="@+id/mEdit"
        android:inputType="numberPassword"
        android:maxLength="4"
        android:singleLine="true"
        app:layout_constraintTop_toTopOf="parent" />

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

这里 maxLengthEditText4。但是,在启用对话后,如果我们尝试在密码字段中编辑某些内容,即使我们没有达到 { maxLength 中的 {1}}。

Incorrect content description is shown when we enter 3rd password charector

预先感谢您提出宝贵意见。

解决方法

com.google.android.material.textfield.TextInputEditText 中使用 EditText 而不是 TextInputLayout