Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Preference Category Styling

Tags:

android

styles

I am trying to change the color of the text and the background of the preference categories. I searched the webs for answers, but nothing seems to be working. Has anyone successfully changed the color of the preference category attributes? Could I use a custom layout to change looks and feel of the preference category? I need some more direction. Please help

Here is what I have so far:

<style name="Theme" parent="@style/android:Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
    <item name="android:background">@color/ab_grey</item>
</style>

<style name="PrefCatStyle" parent="Theme">
    <item name="android:textColor">@color/text_green</item>
    <item name="android:background">@color/pref_back</item>
</style>

colors

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="ab_grey">#adadad</color> <!--  #adadad--> 
    <color name="text_green">#000000</color>
    <color name="pref_back">#FFFFFF</color>
</resources>

Part of my Preference Layout

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory 
        android:title="Settings"
        android:key="settings_category"
        style="@style/PrefCatStyle">

And my part Manifest

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/Theme" > 
...
        <activity
            android:name=".SettingsPrefActivity"
            android:parentActivityName=".MainActivity"
            android:theme="@style/emTextTheme">

Thanks

like image 945
Peter Sun Avatar asked Feb 22 '14 16:02

Peter Sun


People also ask

What are preferences Android?

Preferences in Android are used to keep track of application and user preferences. In any application, there are default preferences that can accessed through the PreferenceManager instance and its related method getDefaultSharedPreferences(Context)

Where is Preferences option in Android Studio?

From the menu bar, click File > Settings (on macOS, click Android Studio > Preferences).

What is preference activity in Android Studio?

PreferencesActivity is a way to easily create preference screens such as those in Android itself, just look under Settings . These can be used inside applications to easily save preferences to SharedPreferences and then easily access these from within your app. See this page for more information on PreferenceActivity.


1 Answers

yes. you can use custom layout. take a look at the answer of this question. Custom PreferenceCategory Headings

like image 78
Kelum Deshapriya Avatar answered Sep 28 '22 04:09

Kelum Deshapriya