EditText无法更改文本颜色

Bla*_*oot 1 android textcolor android-edittext

我试图像这样改变EditText中的文本颜色

 <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" />
Run Code Online (Sandbox Code Playgroud)

但它没有改变这种颜色#B49228就像这样的金色 在此输入图像描述

我的设备 : HoneyWell Delphine 70e

Nab*_*bin 10

提示不会改变颜色.尝试输入文字,它会起作用.由于颜色更改是针对您输入的文本.而且你的颜色代码不正确,第一个EditText 有额外的FF.

编辑:

使用以下更改提示颜色

android:textColorHint="#FFFFFF"
Run Code Online (Sandbox Code Playgroud)


jai*_*min 5

提示颜色和文本颜色是两种不同的东西,使用此代码在文件夹中创建一个color.xml文件,然后像这样在其中添加颜色 #B49228 并像这样 使用它<color name="myColor">#B49228 </color>

 android:textColor="@color/myColor"
Run Code Online (Sandbox Code Playgroud)

并且您正在使用提示文本,以便使用此代码更改提示颜色

  android:textColorHint="@color/myColor"
Run Code Online (Sandbox Code Playgroud)