I've just migrated from support library to AndroidX. Most of my code works fine but suddenly my custom preference theme stoped working.
My app has mostly dark background so I set the text color to white variants but in my settings the background color is light so the title and subtitle of the preferences should be dark variant. During my attempts to customize my preference fragment I used the solution from this -> How to style PreferenceFragmentCompat Sadly, after migrating from support library to AndroidX this solution stopped working.
These are my actual dependencies afhter the migration:
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'com.google.android.material:material:1.1.0-alpha02'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'androidx.preference:preference:1.1.0-alpha02'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
This is my actual theme that used to work.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- General theme colors -->
<item name="colorPrimary">@color/appColorPrimary</item>
<item name="colorPrimaryDark">@color/appColorPrimaryDark</item>
<item name="colorAccent">@color/appColorAccent</item>
<!-- Text Appearance styles -->
<item name="android:textViewStyle">@style/TextViewStyle.Serif</item>
<item name="android:textColorPrimary">@color/textColorPrimary</item>
<item name="android:textColorSecondary">@color/textColorSecondary</item>
<item name="android:textColorTertiary">@color/textColorTertiary</item>
<item name="android:textColorLinkInverse">@color/textColorLinkInverse</item>
<!--For the SearchView cursor color-->
<item name="colorControlActivated">@color/white</item>
<!--Custom styles and themes -->
<item name="preferenceTheme">@style/AppTheme.PreferenceTheme</item>
<item name="actionOverflowMenuStyle">@style/AppTheme.OverflowMenu</item>
<item name="alertDialogTheme">@style/AlertDialogStyle</item>
<!-- Custom attributes defined in attrs.xml -->
<item name="dividerColor">@color/dividerColor</item>
</style>
<!--Preference screen theme-->
<style name="AppTheme.PreferenceTheme" parent="PreferenceThemeOverlay.v14.Material">
<!--Overriding textColor primary/secondary from main theme-->
<item name="android:textColorPrimary">@color/textColorPrimaryInverse</item>
<item name="android:textColorSecondary">@color/textColorSecondaryInverse</item>
<item name="android:colorControlActivated">@color/appColorPrimary</item>
</style>
Is there any solution for this new situation ?