Android: TextInputLayouts 总是有一个错误图标

Android: TextInputLayouts always have an error icon

我注意到几天以来,我所有的 TextInputLayouts 都始终启用 "error exclamation point"。我已经很长时间没有对那些 TextInputLayouts 进行任何更改,所以我真的不明白发生了什么。

这是它的外观截图:

您知道这个问题的根源是什么吗? TextInputLayouts 最近有什么变化吗?

非常感谢您

编辑

相关代码如下: .xml 文件非常简单。这是一个 TextInputLayouts 和 EditTexts 的列表,如下所示:

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="@dimen/default_margin"
    android:layout_marginTop="@dimen/default_margin"
    android:layout_marginRight="@dimen/default_margin">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/txtAddressTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/PROFILE_SCREEN_ADDRESS_INPUT_TITLE"
        android:inputType="textPersonName|textCapWords" />

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

此外,在我的 Kotlin 代码中绝对没有提到 setError()

编辑: 看起来它已通过 com.google.android.material:material:1.2.0-alpha04.

修复

嘿,我发现了问题。我实际上将 Material 库的版本从 com.google.android.material:material:1.1.0-alpha08 版本更新为 com.google.android.material:material:1.1.0-alpha09.

Google 更改了文本字段的行为(请参阅此处:https://github.com/material-components/material-components-android/releases/tag/1.1.0-alpha09):

文本字段:

  • 添加选项以将 TextInputLayout 图标设置为不可检查 (6a88f2b)
  • 为文本字段实现错误图标 (3f73804)

你可以试试这个。但它会永久删除错误图标。如果您想再次显示它,您必须以编程方式进行。

app:errorIconDrawable="@null"