Reputation: 516
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.
Upvotes: 1
Views: 671
Reputation: 13617
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.
Upvotes: 1
Reputation:
This is the easisest way. Just Copy+paste please
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Description">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="textMultiLine"/>
</android.support.design.widget.TextInputLayout>
Upvotes: 0
Reputation: 107
Please try below code:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/mUserEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1"
android:paddingLeft="10dp"
android:textColorHint="@color/hint_color"
android:textSize="13sp" />
</android.support.design.widget.TextInputLayout>
Remove android:textColorHint tag from the style file.
Upvotes: 0
Reputation: 2188
You can apply reverse logic here.Like this:
Hope it works.
Upvotes: 0