I am using the following XML to try and change the colors of a switch in my Xamarin forms application. However nothing changes.
Can anyone give me any advice on what I might be doing wrong:
<style name="MyTheme" parent="MyTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="android:actionBarSize">45dp</item>
<item name="colorPrimaryDark">#1976D2</item>
</style>
<style name="MyTheme.Switch" parent="Widget.AppCompat.CompoundButton.Switch">
<item name="colorControlActivated">#FF0000</item>
<item name="colorControlNormal">#FF0000</item>
<item name="colorControlHighlight">#FF0000</item>
<item name="colorSwitchThumbNormal">#FF0000</item>
<item name="colorAccent">#FF0000</item>
</style>
Here's a clip from MainActivity.cs
[Activity(Label = "Japanese", Icon = "@drawable/Icon120", Theme = "@style/MyTheme", MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
ScreenOrientation = ScreenOrientation.Portrait)]
As this didn't work I tried some changes but same problem in that it doesn't work:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomTheme" parent="@android:style/Theme">
<item name="segmentedControlOptionStyle">@style/SegmentedControlOption</item>
<item name="switchStyle">@style/SwitchCompat</item>
</style>
</resources>
<style name="SwitchCompat" parent="@style/Widget.AppCompat.CompoundButton.Switch">
<item name="colorPrimary">#FFFF00</item>
<item name="colorPrimaryDark">#00FFFF</item>
<item name="colorAccent">#FF00FF</item>
</style>