I know this might be a possible duplicate like
Applying AppCompat theme to individual preferences in a PreferenceFragment
I used this video on youtube: https://www.youtube.com/watch?v=PS9jhuHECEQ
And from devolper android this guideline: https://developer.android.com/guide/topics/ui/settings
to build my preferences. At the moment my preference library is:
implementation 'androidx.preference:preference:1.1.0-beta01'
So now I want to apply my apptheme to my preferences settings...
I got this in my manifest.xml
<application
android:name=".XXXApplication"
android:allowBackup="false"
android:label="@string/W_APP_NAME"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".Views.MainActivity"
android:label="@string/W_APP_NAME"
android:screenOrientation="landscape"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
My styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Now I have a root_preferences.xml which holds several other preferences, like this:
root_preferences.xml
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Preference
app:title="@string/N_CAM_ITEM"
app:summary="@string/P_CAMERA_SETTINGS"
app:icon="@drawable/ic_menu_camera"
app:fragment="com.example.XXX.Views.CameraSettingFragment"/>
And there is also a camera_preferences.xml which is also a PreferenceScreen
that holds SwitchPreferences
and so on...
If I navigate to settings my SettingsFragment
is called..
public class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
setPreferencesFromResource(R.xml.root_preferences, rootKey);
}
So what am I missing, that my theme/style is not applied to those preferences? Hope you can help me out with this!
So checkbox and switch aren't showing any colors... There must be some primary orange green color