Reputation: 446
I have color code #ffa100. I have also define it in values xml as
<color name="orange">#ffa100</color>
I want to find name "orange" based on the color code value "#ffa100" How can I find it? I want to use name of color in program from value where several colors are defined and I get has code from server.
Upvotes: 0
Views: 361
Reputation: 61
Use,
Color.parseColor("#ffa100");
like,
mTextView.setTextColor(Color.parseColor("#ffa100")); //set text color
mTextView.setBackgroundColor(Color.parseColor("#ffa100")); // set background color
Upvotes: 0
Reputation: 1210
You can set it directly from with the hex code, no need to have it in resources. Hex value has to be a String.
your_image.setBackgroundColor(Color.parseColor("#ffa100"))
Upvotes: 1