ImDineshSharma
ImDineshSharma

Reputation: 35

How do i change the color for user input in xml?

THIS IS THE OUTPUT

Whenever I type text in the username field, it appears to be black so you can't see what is being typed because of background and input color is the same. I want it to be white or some other color but not black.

I'm not sure why it's happening because I didn't make any changes to style.xml and in MainActivity.xml I did not set the text color black here are files

<EditText android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="45sp"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_marginTop="293dp"
        android:layout_marginEnd="87sp"
        android:autofill Hints=""
        android:background="#11000000"
        android:drawableStart="@drawable/ic_action_user"
        android:ems="10"
        android:hint="@string/username"
        android:inputType="textPersonName"
        android:textColorLink="#808080"
        android:textColorHint="#808080"/>

My color xml file.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#008577</color>
    <color name="colorPrimaryDark">#00574B</color>
    <color name="colorAccent">#D81B60</color>
</resources>

My style xml file.

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
</resources>



Upvotes: 0

Views: 825

Answers (2)

ImDineshSharma
ImDineshSharma

Reputation: 35

Using the following setting fixes the problem:

android:textColor = "#FFFFFF"

Upvotes: 0

Muhammad Ali
Muhammad Ali

Reputation: 695

In your EditText add textColor like this:

<EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="45sp"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_marginTop="293dp"
        android:layout_marginEnd="87sp"
        android:textColor="#FFFFFF"
        android:autofill Hints=""
        android:background="#11000000"
        android:drawableStart="@drawable/ic_action_user"
        android:ems="10"
        android:hint="@string/username"
        android:inputType="textPersonName"
        android:textColorLink="#808080"
        android:textColorHint="#808080"/>

I have changed your EditText text color to white you can change to any other if you like by changing hex code.

Upvotes: 2

Related Questions