Android: Convert a Hexadecimal Color to an Int in Java

2/17/2014 2:59:53 PM

When developing and Android app, you will at some point want to set the background color of a View. When way to do this is the viewObj.setBackgroundColor(int colorId). To get the correct colorId from a hexadecimal value, use the following.



int colorId = Color.parseColor("#a6a4a4");