Matthew Pans
Matthew Pans

Reputation: 851

Switch Style Issue in MAUI

I'm using a switch on my MAUI project. I found a style issue on Android devices 10 and 11, but on Android 12, there is no style issue.

Below is the screenshot on the Android 10 and Android 11.

enter image description here

Below is the screenshot on the Android 12.

enter image description here

Code:

 <Switch
    x:Name="sms_switch"
    ThumbColor="#5abcd7"
    OnColor="#5abcd7"
    Toggled="SMSToggledEvent"
    VerticalOptions="CenterAndExpand"
    HorizontalOptions="StartAndExpand"/>

Can you please help me to fix this issue?

Upvotes: 1

Views: 544

Answers (2)

Matthew Pans
Matthew Pans

Reputation: 851

I tried a lot of way to fix this UI issue but didn't get any solution. Finally I used switch on and off icons and resolved.

This is not a solution but a way to fix the UI issue.

Upvotes: 1

Liyun Zhang - MSFT
Liyun Zhang - MSFT

Reputation: 14509

I can't reproduce your problem. I created two new projects to test your code.

  1. In the target .net 7.0 project: all of the Android 10 , Android 11 and Android 12 device can have the correct style.
  2. In the target .net 8.0 project: all the versions of android device had the default style.

I used Visual Studio version 17.9.0 Preview 1.1.

In addition, I found the similar issue on the github: Switch thumbcolor cannot be set in code and Switch on Android has wrong initial color. You can follow up them.

Upvotes: 0

Related Questions