我是用从设计库中的新TextInputLayout。我能得到它显示并更改浮动标签的颜色。不幸的是,实际的EditText暗示现在总是白色的。
我曾试图改变hintColor在XML中,样式和编程,也尝试过使用android.support.v7.widget.AppCompatEditText 但淡淡的EditText总是显示为白色。
下面是我的XML我TextInputLayout和的EditText
< android.support.design.widget.TextInputLayout
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
android.support.design:hintTextAppearance="@style/GreenTextInputLayout">
<的EditText
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:ID =@ + ID /城市
机器人:textColorHint =@彩色/黑白
机器人:提示=@字符串/城市/>
< /android.support.design.widget.TextInputLayout>
这里是我使用的TextInputLayout的风格(我试图使hintTextColor属性黑,但并没有为我做任何事情):
<样式名称=GreenTextInputLayout父=@风格/ TextAppearance.AppCompat>
<项目名称=机器人:文字颜色> @色/ homestory_green< /项目>
< /风格>
解决方案
看起来像父视图有一个风格这是导致的EditText是白色的第三方库。
安卓主题=@风格/ com_mixpanel_android_SurveyActivityTheme
在我删除了这一切都能正常工作。
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.
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.
Here is my XML for my TextInputLayout and 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>
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>
解决方案
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.