title: Android set background color to TextView in styles.xml
body: <p>In my application, I want to set a style to the <code>TextView</code> which will make the <code>TextView</code> look like a header as shown in the following figure-</p>
  
  <p><img src="https://i.stack.imgur.com/vqY7p.png" alt="&quot;General&quot; is the heading in this image."></p>
  
  <p>When I apply the style from the <code>styles.xml</code> (given below), it applies the font and font color as specified. But, it does not apply the white background. Can we  at all do this?</p>
  
  <p>The style defined is like this-</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p>
      </p>
  
  <pre><code>&lt;style name="settings_header"&gt;
      &lt;item name="android:layout_marginBottom"&gt; 10dip &lt;/item&gt;
      &lt;item name="android:background"&gt; @color/white &lt;/item&gt;
      &lt;item name="android:paddingLeft"&gt; 10dip &lt;/item&gt;
      &lt;item name="android:layout_width"&gt; match_parent &lt;/item&gt;
      &lt;item name="android:layout_height"&gt; wrap_content &lt;/item&gt;
      &lt;item name="android:textSize"&gt; 22sp &lt;/item&gt;
      &lt;item name="android:textColor"&gt; @color/black &lt;/item&gt;
      &lt;item name="android:textStyle"&gt; bold &lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p></p>
  
  <p>The code which applies the style is like</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  textview = (TextView) findViewById(R.id.textView);
  textview.setTextAppearance(ScrSettings.this,R.style.settings_header);
  }
  </code></pre>