将项目中的android支持库升级到28.0.0后,我无法更改自定义TextInput的提示颜色
我尝试根据状态使用可绘制对象来更改颜色,更改textColor属性,更改textColorHint属性...它们都不起作用,但是如果更改其他提示属性,例如文本大小,则可以使用。
我当前的提示样式:
<style name="TextInputHint" parent="@android:style/TextAppearance">
<item name="android:textColor">@drawable/textinput_hint_color</item>
<item name="android:textSize">@dimen/textSize14</item>
<item name="android:gravity">top</item>
<item name="android:maxLines">4</item>
<item name="android:inputType">textMultiLine</item>
<item name="android:scrollbars">vertical</item>
</style>
可绘制对象
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/northTexasGreen" android:state_focused="true"/>
<item android:color="@color/lightSlateGray" android:state_focused="false"/>
</selector>
答案 0 :(得分:0)
以下代码适用于28.0.0
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/TextInputHint">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Checking hint color"
android:padding="10dp"
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
<style name="TextInputHint" parent="@android:style/TextAppearance">
<item name="android:textColor">@drawable/textinput_hint_color</item>
<item name="android:textSize">@dimen/textSize14</item>
<item name="android:gravity">top</item>
<item name="android:maxLines">4</item>
<item name="android:inputType">textMultiLine</item>
<item name="android:scrollbars">vertical</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/northTexasGreen" android:state_focused="true"/>
<item android:color="@color/lightSlateGray" android:state_focused="false"/>
</selector>