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

Val*_*tin 14 android android-textinputlayout

我注意到几天以来,我所有的 TextInputLayouts 总是启用“错误感叹号”。我已经很长时间没有对那些 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>
Run Code Online (Sandbox Code Playgroud)

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

Var*_*Raj 38

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

app:errorIconDrawable="@null"
Run Code Online (Sandbox Code Playgroud)


Val*_*tin 5

编辑: 看起来它是用com.google.android.material:material:1.2.0-alpha04.


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

谷歌改变了文本字段的行为(见这里:https : //github.com/material-components/material-components-android/releases/tag/1.1.0-alpha09):

文本域:

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