如何改变TextInputLayout的浮动标签颜色颜色、标签、TextInputLayout

2023-09-12 08:39:05 作者:孤城凉梦

参照由谷歌发布了全新的TextInputLayout,我该如何改变浮动标签文本颜色?

With reference to the new TextInputLayout released by Google, how do I change the floating label text color?

在风格设定colorControlNormal,colorControlActivated,colorControlHighLight于事无补。

Setting colorControlNormal, colorControlActivated, colorControlHighLight in styles does not help.

这是我现在有:

推荐答案

找到了答案,用android.support.design:hintTextAppearance属性来设置自己的浮动标签的外观。

Found the answer, use android.support.design:hintTextAppearance attribute to set your own floating label appearance.

例如:

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:hintTextAppearance="@style/TextAppearance.AppCompat">

    <EditText
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/prompt_password"/>
</android.support.design.widget.TextInputLayout>