Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6007563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:41:56+00:00 2026-05-23T01:41:56+00:00

I have a simple preference screen defined like this <PreferenceScreen xmlns:android=http://schemas.android.com/apk/res/android> <PreferenceCategory android:title=Security> <CheckBoxPreference

  • 0

I have a simple preference screen defined like this

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory android:title="Security">
        <CheckBoxPreference 
            android:title="Require Pin on Start"
            android:summary="Require pin to run the application"
            android:key="@string/pref_require_pin"
            android:defaultValue="false" />
    </PreferenceCategory>

    <PreferenceCategory android:title="Settings">
        <ListPreference
           android:title="History Age (in days)"
           android:summary="Display items up to 30 days old"
           android:key="@string/pref_history_days"
           android:defaultValue="30"
           android:entries="@array/days_list"
           android:entryValues="@array/days_list"
           android:dialogTitle="Select History Age"/>
    </PreferenceCategory>
</PreferenceScreen>

I have a style setup already and used elsewhere in my app.

<style name="ListHeader">
    <item name="android:textColor">#000000</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textSize">12sp</item>
    <item name="android:background">#cccccc</item>
    <item name="android:paddingTop">6px</item>
    <item name="android:paddingBottom">6px</item>
    <item name="android:paddingLeft">12px</item>
</style>

and here is my activity

public class PreferencesActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        addPreferencesFromResource(R.layout.preferences);
    }
}

How do I apply my custom style to the PreferenceCategory heading?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:41:57+00:00Added an answer on May 23, 2026 at 1:41 am

    You should take a look at Preference.Category style:

    <style name="Preference.Category">
        <item name="android:layout">@android:layout/preference_category</item>
       <item name="android:shouldDisableView">false</item>
       <item name="android:selectable">false</item>
    </style>
    

    Let’s take a look at preference_category.xml file:

    <!-- Layout used for PreferenceCategory in a PreferenceActivity. -->
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        style="?android:attr/listSeparatorTextViewStyle"
        android:id="@+android:id/title"
    />
    

    So you need to create custom theme that extends default android Theme and override listSeparatorTextViewStyle value with ListHeader style. And then apply this theme to Activity that extends PreferenceActivity .


    Here is how you can do it.

    First, in your styles.xml add next code:

    <style name="PreferenceListHeader" 
           parent="@android:style/Widget.TextView.ListSeparator">
    
        <item name="android:textColor">#000000</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">12sp</item>
        <item name="android:background">#cccccc</item>
        <item name="android:paddingTop">6px</item>
        <item name="android:paddingBottom">6px</item>
        <item name="android:paddingLeft">12px</item>
    </style>
    
    <style name="Theme.Custom" parent="@android:style/Theme">
        <item name="android:listSeparatorTextViewStyle">@style/PreferenceListHeader</item>               
    </style>
    

    Then in your AndroidManifest.xml add theme to your preference acitivity:

     <activity android:name=".MyPreferencesActivity" 
               android:theme="@style/Theme.Custom" 
               ... >
     ...
     </activity>
    

    Here is a screenshot:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create simple editor screen - similar to the Add Event
I have written a custom preference class which contains a simple progress bar in
I am working to implement some simple preferences to an app I have and
I have a simple idea: I want to draw a line in 3d space
I have a small ap with preferences. In this class I've set the onPreferenceClick
I have a control written in C++ using WinAPI and I would like to
I am using logging module of python. How can I access the handlers defined
I have Camera class, which handles camera behavior. Among it's fields is a reference
I have the following markup in an MVC 3 Razor view. As is, the
I'm a noob working on my first app that consists of the following: Main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.