Change PreferenceActivity text color

13,213

I assume you use an Activity which extends the PreferenceActivity. You can use the setTheme method to set a custom theme on your preference screen. Just define one in res/values/themes.xml.

It would look like this:

<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
  <style name="Theme.DarkText">
    <item name="android:textColor">#000000</item>
  </style>
</resources> 

Afterwards set it in your Activity:

setTheme(R.style.Theme_DarkText);
Share:
13,213
guilherme.minglini
Author by

guilherme.minglini

Updated on June 17, 2022

Comments

  • guilherme.minglini
    guilherme.minglini about 2 years

    I want to change the look of my Android app's preference screen to dark text color. How can I do this? (I´ve already changed the background to white color)

  • Rudey
    Rudey almost 11 years
    What if you want to change the text color after the layout is constructed?
  • shantanu
    shantanu over 10 years
    @MarioB This code can change the title text color of preferences except EditTextPreference. What the name of attribute for EditTextPreference's title (not dialog title)?
  • Display Name
    Display Name almost 10 years
    Won't work when there are more items that the screen can fit, because ListView implements view recycling and doesn't create all views