How do you change the color of an Android toggle button in a Theme

70 Views Asked by At

I'd like to change the color of a toggle button (Material) via my theme.xml:

  • background needs to be black
  • green line needs to be purple when the toggle is on

I have tried to use backgroundTint but the line diseappears entirely. Any idea?

<style name="Theme.GymTimerDark" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="colorPrimary">@color/purple_500</item>
    <item name="colorPrimaryDark">@color/black</item>
    <item name="colorAccent">@color/purple_200</item>
    <item name="android:colorBackground">@color/white</item>
    <item name="android:textColor">@color/black</item>
    <item name="android:buttonStyleToggle">@style/Theme.GymTimerLight.buttonStyleToggleDark</item>
</style>

<style name="Theme.GymTimerLight.buttonStyleToggleDark" parent="android:Widget.Material.Button.Toggle">
    <item name="android:backgroundTint">@color/black</item>
    <item name="android:textColor">@color/white</item>
</style>

(I'm using com.google.android.material:material:1.5.0-alpha02)

0

There are 0 best solutions below