Define android:textColorHint
in your application theme:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:textColorHint">@color/secondary_text</item>
</style>
Source
Create custom style in style.xml
<style name="EditTextHint" parent="TextAppearance.AppCompat">
<item name="colorAccent">@android:color/white</item>
<item name="android:textColorHint">@color/BackgroundtWhiteColor</item>
<item name="colorControlNormal">@color/BackgroundtWhiteColor</item>
<item name="colorControlActivated">@color/your color</item>
<item name="colorControlHighlight">@color/BackgroundtWhiteColor</item>
</style>
Then in your layout xml file, add theme attribute as below
<android.support.design.widget.TextInputLayout
android:theme="@style/EditTextHint"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>
hope this works
Add textColorHint property to your edit text
android:textColorHint="#F6F6F6"
or whichever color you want
got the same problem. Resolved by putting these lines in parent theme.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/ColorPrimaryDark</item>
<item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
<item name="colorAccent">@color/AccentColor</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:textColorHint">@color/BackgroundtWhiteColor</item>
<item name="colorControlNormal">@color/BackgroundtWhiteColor</item>
<item name="colorControlActivated">#ff0000</item>
<item name="colorControlHighlight">@color/BackgroundtWhiteColor</item>
<!-- Customize your theme here. -->
</style>
If you put these
<item name="android:textColorHint">@color/BackgroundtWhiteColor</item>
<item name="colorControlNormal">@color/BackgroundtWhiteColor</item>
<item name="colorControlActivated">#ff0000</item>
<item name="colorControlHighlight">@color/BackgroundtWhiteColor</item>
in a separate style and apply it to TextInputLayout or Edittext it won't appear. You HAVE to place it in application's parent theme.
I'm not sure what causes your problem put this code works perfectly for me. I think it has something to do with using the correct xml namespace (xmlns
). I'm not sure if using android.support.design without xml namespace attribute is supported. Or it has something to do with the textColorHint
attribute you are using on the EditText itself.
Layout:
<android.support.design.widget.TextInputLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
app:hintTextAppearance="@style/GreenTextInputLayout">
<android.support.v7.widget.AppCompatEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="test"
android:inputType="text" />
</android.support.design.widget.TextInputLayout>
Style:
<style name="GreenTextInputLayout" parent="@android:style/TextAppearance">
<item name="android:textColor">#00FF00</item>
</style>
Refer the below code it worked for me.But it will affect all your controls color.
<!-- In your style.xml file -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!--EditText hint color-->
<item name="android:textColorHint">@color/default_app_white</item>
<!-- TextInputLayout text color-->
<item name="colorControlActivated">@color/default_app_green</item>
<!-- EditText line color when EditText on-focus-->
<item name="colorControlHighlight">@color/default_app_green</item>
<!-- EditText line color when EditText in un-focus-->
<item name="colorControlNormal">@color/default_app_white</item>
</style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With