2

I have a white Switch on white background. The default switch toggle elevation seems to be to low which results in the toggle blending with the switch and background. I know there is Modifier.shadow that can be applied to modifier, however Switch does not expose the toggle view and its modifier (as far as I figured). So is there a way to control the elevation in such a case? enter image description here

This is what I want to achieve.

enter image description here

Sermilion
  • 1,920
  • 3
  • 35
  • 54

1 Answers1

2

I had the same problem, but there's no easy solution for adding elevation without creating a custom composable. My solution was to change the Switch colors so it doesn't blend into the background. You can do that by modifying the SwitchDefaults.colors, and in the simplest case, you just need to use a different uncheckedThumbColor (in my case, I changed it to a light blue-grey color):

        Switch(
            ...
            colors = SwitchDefaults.colors(
                uncheckedThumbColor = BlueGrey50
            )
            ...
        )

where val BlueGrey50 = Color(0xFFeceff1)

user496854
  • 6,461
  • 10
  • 47
  • 84