首页 > 解决方案 > TextInputLayout HelperText 激活时不改变颜色

问题描述

我有一个具有以下主题的 TextInputLayout:

<style name="TextInputLayoutTheme" parent="Widget.Design.TextInputLayout">
    <item name="colorControlNormal">@color/grey</item>
    <item name="colorControlActivated">@color/blue</item>
</style>

和 helperTextTextAppearance:

<style name="TextInputLayoutHelperText" parent="TextAppearance.Design.HelperText">
    <item name="android:textColor">@color/helper_text_color</item>
</style>

和 helper_text_color xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/blue" android:state_focused="true" />
    <item android:color="@color/grey" android:state_focused="false" />
</selector>

对于 EditText 和提示文本,这很好用:当我点击 TIL 并聚焦时,它是灰色的并变成蓝色。
但是 helperText 一直保持灰色 - 我希望它也变为蓝色。
我也尝试将其更改为,<item android:color="@color/blue" android:state_activated="true" />但它也不起作用。
我需要如何定义helperTextTextAppearance以确保它根据 改变它的颜色colorControlActivated

标签: androidandroid-textinputlayout

解决方案


推荐阅读