Android: Get the Background Color of a View

2/17/2014 3:01:51 PM

The following code will get the background color of a view and convert it to the int representation of the color.

ColorDrawable buttonColor = (ColorDrawable) myView.getBackground();
int colorId = buttonColor.getColor();