The following methods show how you can set the background colour of a TextView object when developing Android applications using the SDK.
There are two ways to change the background colour.
Method 1
Simply use setBackgroundColor to specify a colour directly.
TextView tv = new TextView(activity);
tv.setBackgroundColor(0xffff0000);
<resources>
<color name="white">#ffffffff</color>
<color name="black">#ff000000</color>
<color name="red">#ffff0000</color>
<color name="green">#ff00ff00</color>
<color name="blue">#ff0000ff</color>
</resources>
TextView tv = new TextView(activity);
tv.setBackgroundResource(R.color.red);