Android 如何在材质设计文本InputLayout中实现错误消息的旧外观?

Android 如何在材质设计文本InputLayout中实现错误消息的旧外观?,android,material-design,androidx,Android,Material Design,Androidx,我正在使用com.google.android.material.textfield.TextInputLayout,并且 正在尝试实现输入字段的外观,如第一幅图像上所示: 但它以这种方式呈现错误消息: 如何使它看起来像第一张照片 更新: 这是我的xml: <com.google.android.material.textfield.TextInputLayout android:id="@+id/tilEmail" android:layout_wid

我正在使用com.google.android.material.textfield.TextInputLayout,并且 正在尝试实现输入字段的外观,如第一幅图像上所示:

但它以这种方式呈现错误消息:

如何使它看起来像第一张照片

更新: 这是我的xml:

<com.google.android.material.textfield.TextInputLayout
        android:id="@+id/tilEmail"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toEndOf="@id/ivContactIcon"
        app:layout_constraintEnd_toEndOf="@id/gEnd"
        app:layout_constraintTop_toBottomOf="@id/tilHomePhone"
        app:errorEnabled="true"
        android:hint="@string/profile_edit_hint_email"
        >

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/etEmail"
          style="@style/FontRoboRegularSizeMFontPrimaryOneLineMatchWrap"
            android:inputType="textEmailAddress"
            android:imeOptions="actionDone"
            />
    </com.google.android.material.textfield.TextInputLayout>

试试这个:

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/hint_text">

  <com.google.android.material.textfield.TextInputEditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"/>

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

在这里你可以选择错误

app:errorEnabled
setError(CharSequence)

试试这个:

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/hint_text">

  <com.google.android.material.textfield.TextInputEditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"/>

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

在这里你可以选择错误

app:errorEnabled

setError(CharSequence)

在电子邮件输入中输入一些文本时,如第一张图片或第二张图片,如何产生此错误?第一张图片只是在Photoshop中制作的设计,您需要在
TextInputLayout
上调用
setError()
,而不是
TextInputItemText
@MikeM。哇!这是正确的。你能创建一个答案而不是评论吗?事实上,这是一个常见的问题,以前在这里已经回答过了,所以我将把它标记为一个副本。不过谢谢你。谢谢你的提议。很高兴你让它工作了。干杯当您在电子邮件输入中输入一些文本时,如第一张图片或第二张图片,您是如何得到此错误的?第一张图片只是在Photoshop中制作的一个设计。您需要调用
TextInputLayout
上的
setError()
,而不是
textinputtext
@MikeM。哇!这是正确的。你能创建一个答案而不是评论吗?事实上,这是一个常见的问题,以前在这里已经回答过了,所以我将把它标记为一个副本。不过谢谢你。谢谢你的提议。很高兴你让它工作了。干杯错误已启用,但我需要它的另一个外观删除
style=“@style/FontRoboRegularSizeMFontPrimaryOneLineMatchWrap”
并替换为
style=“@style/Widget.MaterialComponents.TextInputLayout.OutlineBox”
错误已启用,但我需要它的另一个外观删除
样式=“@style/FontRoboRegularSizeMFontPrimaryOneLineMatchWrap”
并替换为
style=“@style/Widget.MaterialComponents.TextInputLayout.OutlineBox”