Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid set background color to TextView in styles.xml
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload