在非焦点状态下使用 TextInputLayout 时提示不可见

Hint not visible with TextInputLayout on non focus state

我正在使用 Android 设计库中的新 TextInputLayout

EditText被聚焦时,一切正常,我可以看到EditText上方的提示:

但是当EditText失去焦点时,提示就完全消失了:

我希望提示 return 到 EditText,我错过了什么?

xml 下面的代码。

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="20dp">

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Try me!"/>
    </android.support.design.widget.TextInputLayout>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:hint="Try me 2"/>
</LinearLayout>

此问题自 22.2.1 起已修复,请更新您的 Android SDK。

我的 SDK 已更新,因此接受的答案对我不起作用。

我的解决方法是设置自定义样式或覆盖某些道具:

android:textColorHintapp:boxStrokeColorapp:hintTextColor

颜色值
<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/input_layout"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Edit Text"
    android:textColorHint="@color/some_color"
    app:boxStrokeColor="@color/some_color"
    app:hintTextColor="@color/some_color"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

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

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