Search code examples
androidandroid-layoutandroid-preferences

Change textColorSecondary for PreferenceThemeOverlay


I have white textColorSecondary in AppTheme

<style name="AppTheme" parent="Theme.AppCompat.DayNight">
    ...
    <item name="android:textColorSecondary">#ffffff</item>
    <item name="preferenceTheme">@style/AppTheme.PreferenceTheme</item>
    ...
</style>

And black textColorSecondary in PreferenceTheme

<style name="AppTheme.PreferenceTheme" parent="PreferenceThemeOverlay">
    <item name="android:textColorSecondary">#000000</item>
</style>

But preference summary (which should have the colour of textColorSecondary) is still white.

enter image description here

How can I make it black?


Solution

  • The right thing to do was to create a new theme for SettingsActivity and set it in AndroidManifest

    So, in styles.xml:

    <style name="AppTheme" parent="Theme.AppCompat.DayNight">
        ...
        <item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
    </style>
    
    <style name="PreferenceTheme" parent="AppTheme">
        <item name="android:textColorSecondary">#000000</item>
    </style>
    

    And in AndroidManifest.xml:

    <activity
            android:name=".activity.SettingsActivity"
            ..
            android:theme="@style/PreferenceTheme"
            />