Convert Hex Color Value ( #ffffff ) To Integer Value


Answer :

The real answer is to use:



Color.parseColor(myPassedColor) in Android, myPassedColor being the hex value like #000 or #000000 or #00000000.



However, this function does not support shorthand hex values such as #000.



Answer is really simple guys, in android if you want to convert hex color in to int, just use android Color class, example shown as below



this is for light gray color



Color.parseColor("#a8a8a8");


Thats it and you will get your result.



Integer.parseInt(myString.replaceFirst("#", ""), 16) 


Comments