android:background - Set the Background Color for a TextView

How to Set the Background Color in a TextView

added in API Level 1

This will change the background color of a TextView. A drawable to use as a background. Can be an image, color, PNG image, 9-patch, XML state list description, etc)

1. Add a TextView.

2. In the main.xml file, add the below line. (black background)

  <TextView
    ....
      android:background = "#000000" 
  />
 
3. Determine the Hex color you would like and update above line.

4. Compile and run!

Related Articles