Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should take a look at <a href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/res/res/values/styles.xml;h=d7b654e49809cb97a35682754b1394af5c8bc88b;hb=HEAD#l595" rel="noreferrer"><code>Preference.Category</code></a> style:</p> <pre><code>&lt;style name="Preference.Category"&gt; &lt;item name="android:layout"&gt;@android:layout/preference_category&lt;/item&gt; &lt;item name="android:shouldDisableView"&gt;false&lt;/item&gt; &lt;item name="android:selectable"&gt;false&lt;/item&gt; &lt;/style&gt; </code></pre> <p>Let's take a look at <code>preference_category.xml</code> file:</p> <pre><code>&lt;!-- Layout used for PreferenceCategory in a PreferenceActivity. --&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/listSeparatorTextViewStyle" android:id="@+android:id/title" /&gt; </code></pre> <p>So you need to create custom theme that extends default android <code>Theme</code> and override <code>listSeparatorTextViewStyle</code> value with <code>ListHeader</code> style. And then apply this theme to Activity that extends <code>PreferenceActivity</code> .</p> <hr> <p>Here is how you can do it. </p> <p><strong>First</strong>, in your <code>styles.xml</code> add next code:</p> <pre><code>&lt;style name="PreferenceListHeader" parent="@android:style/Widget.TextView.ListSeparator"&gt; &lt;item name="android:textColor"&gt;#000000&lt;/item&gt; &lt;item name="android:textStyle"&gt;bold&lt;/item&gt; &lt;item name="android:textSize"&gt;12sp&lt;/item&gt; &lt;item name="android:background"&gt;#cccccc&lt;/item&gt; &lt;item name="android:paddingTop"&gt;6px&lt;/item&gt; &lt;item name="android:paddingBottom"&gt;6px&lt;/item&gt; &lt;item name="android:paddingLeft"&gt;12px&lt;/item&gt; &lt;/style&gt; &lt;style name="Theme.Custom" parent="@android:style/Theme"&gt; &lt;item name="android:listSeparatorTextViewStyle"&gt;@style/PreferenceListHeader&lt;/item&gt; &lt;/style&gt; </code></pre> <p><strong>Then</strong> in your <code>AndroidManifest.xml</code> add theme to your preference acitivity:</p> <pre><code> &lt;activity android:name=".MyPreferencesActivity" android:theme="@style/Theme.Custom" ... &gt; ... &lt;/activity&gt; </code></pre> <p>Here is a screenshot:</p> <p><img src="https://i.stack.imgur.com/20k86.png" alt="enter image description here"></p>
 

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