set foreground color in FrameLayout in android programmatically

Bhavesh Hirpara picture Bhavesh Hirpara · Jan 23, 2013 · Viewed 13.5k times · Source

I want to set foreground color in FrameLayout pragmatically (not in XML attribute). I have the color codes in RGB

How can I convert color to drawable...

frm.setForeground(Drawable);

Help!! Thanks

Answer

Vladimir Mironov picture Vladimir Mironov · Jan 23, 2013

You can create a Drawable from color:

final int color = 0xFFFF0000;
final Drawable drawable = new ColorDrawable(color);