I need to change the colour of the unfocused edittext hinttext colour
in TextinputLayout
. I tried like below. Everything works fine except hint text colour of unfocused edittext
. What am i doing wrong here?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/AppTheme">
<EditText
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:hint ="Email"
android:maxLines="1"
android:textColor="#000000" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/AppTheme">
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/passwordText"
android:hint="Password"
android:maxLines="1"
android:textColor="#000000"
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
And my style:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorAccent</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorHint">@color/colorAccent</item>
<item name="android:textSize">18sp</item>
<item name="colorControlNormal">#6E6D6D</item>
</style>
Above image is my output, if Email edittext is highlighted means, Password field hinttextcolor should be grey color like password field grey line.
All you have to do is just removing some lines from your code. Remove unnecessary styles from your styles
and remove app:hintTextAppearance="@style/AppTheme"
from your TextinputLayout
.
Your style
should be like this.
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorAccent</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textSize">18sp</item>
</style>
Your XML
should be like this.
<android.support.design.widget.TextInputLayout
android:textColorHint="#404040" // Change color as per your wish
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:hint ="Email"
android:maxLines="1"
android:textColor="#000000" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_marginTop="10dp"
android:textColorHint="#404040" // Change color as per your wish
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/passwordText"
android:hint="Password"
android:maxLines="1"
android:textColor="#000000"
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>
I have tested it. It will work for you.