EditText unable to change the text color
Asked Answered
C

4

1

I;m trying to change text color in EditText like this

 <EditText
        android:id="@+id/txtUserName"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="5dp"
        android:gravity="right"
        android:hint="@string/hint_user_name"
        android:textColor="#B49228FF" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/txtPassword"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="50px"
        android:gravity="right"
        android:hint="@string/hint_password"
        android:inputType="textPassword"
        android:textColor="#B49228" />

but it doesn't change this color #B49228 is gold it appears like this enter image description here

My Device : HoneyWell Delphine 70e

Consequential answered 5/8, 2014 at 8:38 Comment(0)
H
12

Hint doesn't change color. Try typing text, it will work. As the color change is for text that you input. And also your color code is incorrect, has extra FF for first EditText.

Edited:

Use the following to change hint color

android:textColorHint="#FFFFFF"
Hilariohilarious answered 5/8, 2014 at 8:40 Comment(2)
you are correct man :) it Slip inadvertently hhhhhh I'm waiting to make it correct answerConsequential
yes the first answer is incorrect but after editing it's true :) and both of your answer and @jaimin answer add knowledge for me ThanksConsequential
B
5

Hint color and Text Color are two different thing use this codes create a color.xml file in values folder then add color #B49228 in it like this <color name="myColor">#B49228 </color> and use it like this

 android:textColor="@color/myColor"

and you are using hint text so to change hint color use this code

  android:textColorHint="@color/myColor"
Backed answered 5/8, 2014 at 8:42 Comment(4)
android:textColorHint="@color/myColor" this is new it work to change hint color @HilariohilariousConsequential
the solution of this answer is so obvious. that it may have same answersBacked
i think this is what you want @ConsequentialBacked
It is now correct. He has now edited to be correct :-) So I too voted it.Hilariohilarious
P
1
android:textColorHint="#FFFFFF"

Please try.

Pilot answered 5/8, 2014 at 8:57 Comment(0)
W
-1

put in color.xml your color like

<color name="mytextColor">#B49228</color>

and use this

android:textColor="@color/mytextColor"
Walke answered 5/8, 2014 at 17:4 Comment(1)
incorrect answer check @Backed answer history this part jaimin add which make his answer correct ****and you are using hint text so to change hint color use this code** android:textColorHint="@color/myColor"**Consequential

© 2022 - 2024 — McMap. All rights reserved.