使用 TextInputLayout 时更改 EditText 提示颜色 [英] Change EditText hint color when using TextInputLayout
问题描述
我正在使用设计库中的新 TextInputLayout
.我能够让它显示并更改浮动标签的颜色.不幸的是,实际的 EditText
提示现在总是白色的.
I am using the new TextInputLayout
from the design library. I am able to get it to show and to change the color of the floating label. Unfortunately the actual EditText
hint is now always white.
我曾尝试以编程方式更改 XML、样式和程序中的提示颜色,还尝试使用 android.support.v7.widget.AppCompatEditText
但 EditText
提示总是显示白色.
I have tried changing the hintColor in XML, styles, and programmatically and also tried using the android.support.v7.widget.AppCompatEditText
but the EditText
hint always shows white.
这是我的 TextInputLayout
和 EditText
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android.support.design:hintTextAppearance="@style/GreenTextInputLayout">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/city"
android:textColorHint="@color/black"
android:hint="@string/city" />
</android.support.design.widget.TextInputLayout>
这是我用于 TextInputLayout
的样式(我尝试将 hintTextColor
属性设为黑色,但没有为我做任何事情):
And here is the style I am using for the TextInputLayout
(I tried making the hintTextColor
attribute black but didn't do anything for me):
<style name="GreenTextInputLayout" parent="@style/TextAppearance.AppCompat">
<item name="android:textColor">@color/homestory_green</item>
</style>
推荐答案
看起来父视图有一个用于导致 EditText 为白色的第 3 方库的样式.
Looks like the parent view had a style for a 3rd party library that was causing the EditText to be white.
android:theme="@style/com_mixpanel_android_SurveyActivityTheme"
一旦我删除了它,一切就正常了.
Once I removed this everything worked fine.
这篇关于使用 TextInputLayout 时更改 EditText 提示颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!