androidthemessamsung-mobile

How to change the switch button color in preferences screen?


I am using the "SettingsTheme" for a preferences screen in my app with its parent theme being "Theme.DeviceDefault.Settings". How can I change the color of the switch button and the checkbox in this theme on SAMSUNG devices? The configuration below only changes the colors on other devices.

My styles-v23 xml:

<resources>
<style name="AppTheme" parent="android:Theme.DeviceDefault">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowActionBar">true</item>
    <item name="android:windowNoTitle">false</item>
    <item name="android:statusBarColor">@color/colorPrimaryDark</item>
    <item name="android:backgroundTint">@color/colorBack</item>
    <item name="android:navigationBarColor">@color/colorPrimary</item>
    <item name="android:actionBarStyle">@style/TransparentActionBar</item>
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:actionOverflowButtonStyle">@android:style/Widget.DeviceDefault.ActionButton.Overflow</item>
    <item name="android:popupMenuStyle">@android:style/Widget.DeviceDefault.PopupMenu</item>
</style>
...
<style name="SettingsTheme" parent="android:Theme.DeviceDefault.Settings">
    <item name="colorPrimary">@color/colorPrimaryDark</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:colorPrimary">@color/colorPrimaryDark</item>
    <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:colorAccent">@color/colorBack</item>
    <item name="android:statusBarColor">@color/colorPrimaryDark</item>
    <item name="android:colorBackground">@android:color/white</item>
    <item name="android:windowActionBar">true</item>
    <item name="android:windowNoTitle">false</item>
    <item name="android:logo">@android:color/transparent</item>
    <item name="android:textColorPrimary">@android:color/white</item>
    <item name="android:textColor">#000000</item>
    <item name="android:textColorPrimaryInverse">@android:color/widget_edittext_dark</item>
    <item name="android:colorButtonNormal">#000000</item>
    <item name="android:titleTextColor">#FFFFFF</item>
    <item name="android:alertDialogTheme">@style/AlertDialogTheme</item>
</style>

Solution

  • If someone needs it, this resolved the problem.

    <item name="android:colorControlActivated">@color/mySwitchColor</item>