0
votes

I'm using PreferenceActivity to add PreferenceFragments to my layout. PreferenceActivity is using a custom style with parent Theme.AppCompat.Light.NoActionBar for which I have updated colorPrimary, colorPrimaryDark, and colorAccent. On lollipop, the preference screen appears as expected, using the appropriate color and text styles, however, on KitKat, the style I am using appears to be totally ignored.

Originally I thought the issue was that PreferenceActivity extends Activity not AppCompatActivity, but I even tried using an AppCompatDelegate within my preference activity and that does not help. Why are <21 devices ignoring the style within the preference activity?

1
Is it the alert dialog that is ignoring the theme?Aditya Naique
No, each PreferenceCategory and the ListPreference items under them.tommy
i think the theme Theme.AppCompat.Light.NoActionBar is for higher api and maynot be supported by older versions.Muyide Ibukun
@Ibukun nope. v7 AppCompat library supports all the APIs down to 7.Aditya Naique
oh, i see, thanks @AdityaNaikMuyide Ibukun

1 Answers

0
votes

I think you can fix the issue by making a custom style for the dialogs, and then refer it in your base app theme using the dialogTheme and alertDialogTheme attributes.

<!-- Your base app theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        ...
       <item name="dialogTheme">@style/MyDialogStyle</item>
       <item name="alertDialogTheme">@style/MyDialogStyle</item>
</style>

<!-- Custom style for dialogs -->    
<style name="MyDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
            <item name="colorAccent">@color/accent_pink_a200</item>
            <item name="android:textColorPrimary">@color/white</item>
            <item name="android:textColorSecondary">@color/white</item>
            <item name="android:background">@color/primary_deepPurple_500</item>
            <item name="textColorAlertDialogListItem">@color/white</item>
            <item name="android:textAppearanceButton">@style/TextAppearance.Widget.AppCompat.Toolbar.Title</item>
</style>

You can also include other attributes like colorPrimary and colorPrimaryDark in the custom style as per your need.