I want to display the TextView's text at particular color in which i am getting from server. From server colors are coming in string format. Like "YELLOW", "BLUE", "RED", "PURPLE" etc. How can we set this color to textview's text.
Can anybody have any idea about this?
Thanks
If the server cannot send hex format as Redwarp's comment says, you can do basic colours like this;
Color.parseColor("RED")
Docs
Parse the color string, and return the corresponding color-int. If the string cannot be parsed, throws an IllegalArgumentException exception. Supported formats are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray', 'grey', 'lightgrey', 'darkgrey', 'aqua', 'fuschia', 'lime', 'maroon', 'navy', 'olive', 'purple', 'silver', 'teal'
or create a color.xml
in the values resource folder and create the colour resources like this;
<color name="white">#FFFFFF</color>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With