Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Android: Switch is cut off in off state

SebastianKruseSebastianKruse USMember ✭✭✭

I don't know why, the much bigger iOS Switch has no problem (and there is enough space for the switch) but some of my Android Switches are missing a bit in off state. As you can see in the attached screenshot (it is the very same switch), the on state is no problem but in off state it misses a bit. Is there a way how I can force it to have enough space / use the available space to render fully?


Tagged:

Answers

  • JohnHardmanJohnHardman GBUniversity admin
    edited June 2018

    @SebastianKruse - Is it possible that when you change the state of the Switch that something else is being updated on the Page as well? i.e. could something be overlaid on top of the Switch, or could the Layout have changed to reduce the Width available for the Switch? (assuming you captured those two images in the same way, the one in the off state appears to have shifted left slightly or appears to have had its Width reduced)

  • SebastianKruseSebastianKruse USMember ✭✭✭
    edited June 2018
    @JohnHardman the offset is because I cut this part from screenshots and I might not hit 100% the same spot. There is also nothing that overlays or anything else. It happens to 100% if you rotate the switch by -90. In this case this always happens to the off state no matter how the switch is placed. At least iOS works fine but this is a pretty ugly thing for Android.
  • JohnHardmanJohnHardman GBUniversity admin
    edited June 2018

    @SebastianKruse - Without seeing your XAML or code, it's impossible to identify the cause. However, what I would suggest is to (temporarily) give every other View on the page a different BackgroundColor and give the page itself a different BackgroundColor. The reason for this suggestion is that it does appear that on Android, the Xamarin.Forms Switch can either get hidden behind other Views or get clipped. Whilst I don't see this normally, if I set the Rotation property of a Switch to 90 and do nothing else, I do see this happen (using XF 2.4). Changing the BackgroundColor properties might help identify precisely what is happening, or at least help find a workaround.

    BTW - if that's "pretty ugly" on Android, you should see what happens on UWP with Rotation set to 90 ;-)

  • SebastianKruseSebastianKruse USMember ✭✭✭
    edited June 2018

    @JohnHardman as I already say, there is nothing that limits the switch in any way. It has enough space to expand to it’s full width. The much bigger iOS Switch has in the very same spot in the very same XAML no problem. If a Switch is roatated by -90 this also happens if the switch is the only control in a otherwise complete empty XAML page. The problem with the displayed switch looks like the switch does not occupies enough space for itself because in this case it is placed in a Auto Grid Column. The bad thing: Even if I set the Switch to a width of 300 it moves all other controls away from it but still cuts itself in off state.

    About UWP: Who develops for this platform anyway? Even through the Windows Store the user base is close to non existent. UWP is still not even close to WPF or other native code.

Sign In or Register to comment.