Khalil Bz
Khalil Bz

Reputation: 607

TextColor in Android XML is not working?

I have an android app where I have a textview to represent a question :

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is a very very very very very long Question ?"
android:textSize="40dp"
android:layout_marginBottom="30dp"
android:id="@+id/question"
android:textColor="#d0d0"
android:textColorHint="#d0d0"
android:textColorLink="#d0d0"
android:textColorHighlight="#d0d0"
android:background="#d0d0d0"/>

#d0d0 = Light Green

As you see I've tried all of:

android:textColor="#d0d0"
android:textColorHint="#d0d0"
android:textColorLink="#d0d0"
android:textColorHighlight="#d0d0"

But the Text view Color still the same (Gray) in the phone But in Android studio it's working fine

I don't want a java solution I want to change the color with XML

Thank you in advance

Upvotes: 1

Views: 4759

Answers (5)

Abhinav Saxena
Abhinav Saxena

Reputation: 2044

Agreed with @Kona Suresh, but :

the string format of color in the resources is #AARRGGBB: A for alpha (ff for highest opacity and 00 for lowest transparency), R for red, G for green and B for the blue component of the color. Eg. #ff000000 is pure black color, while #00000000 is transparent black.

Upvotes: 0

Khalil Bz
Khalil Bz

Reputation: 607

I did somethings and now it's working Fine (Windows/Mac/Linux):

1. Backup your SDK Folder (After Installing all the packages)

2. Reinstall Android Studio

3. Get back your SDK folder (override the new one if it exists).

4. If you have an old project Copy only your XML files and the Java files because maybe there is a problem in the other files

I hope it works for any one have the same problem ^_^

Upvotes: 1

Tausif Shahbaz
Tausif Shahbaz

Reputation: 174

You could have checked by using the Analog colour selector instead of putting the hex code in Android studio. Your code seems fine. There is no reason it won't work. All the best.

Upvotes: 1

Kona Suresh
Kona Suresh

Reputation: 1854

Colors are Represented in 4 bytes: alpha, red, green, blue. Each value range 0 to 255. You try to represent the color codes with hexadecimal format #RRGGBB. It should work. It is traditional way in android xml files.

In my mobile your code is working. But may be some mobiles follows only hexadecimal format color representation.

Upvotes: 1

Ratnesh
Ratnesh

Reputation: 65

Text color is code wrong

d0d0 - gray color

For light green Check this link green color

Upvotes: 1

Related Questions