Create a new color drawable

It should be like this...

ColorDrawable cd = new ColorDrawable(0xffff6666);

Note I used 8 hex digits, not 6 hex digit . which add to transparency


For using with ContextCompat and rehuse the color you can do something like this:

ColorDrawable colorDrawable = new ColorDrawable(ContextCompat.getColor(this, R.color.white));

Since you're talking about hex you have to start with 0x and don't forget the opacity.

So basically: 0xFFFF6666

ColorDrawable cd = new ColorDrawable(0xFFFF6666);

You can also create a new colors.xml file into /res and define the colors like:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="mycolor">#FF6666</color>
</resources>

and simply get the color defined in R.color.mycolor

getResources().getColor(R.color.mycolor)