Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Switch tag misbehaving on Android (not iOS)

$
0
0

Hi.

I've had this control working for ages, but noticed last week when doing some regression testing on Android, that it has mysteriously stopped working for switches where the initial value is true...

            <StackLayout Orientation="Horizontal" Spacing="0">
                <Label Text="Show Subscription Cost" Font="{x:Static statics:Fonts.SubTitle}" TextColor="{x:Static statics:Palette.SubTitle}" VerticalOptions="Center" />
                <StackLayout Orientation="Horizontal" Spacing="0" HorizontalOptions="EndAndExpand">
                    <BoxView IsVisible="{Binding GraphMode}" Color="{x:Static statics:Palette.LemongrassGreen}" WidthRequest ="20" HeightRequest="20" VerticalOptions="Center" HorizontalOptions="EndAndExpand"/>
                    <Switch IsToggled="{Binding Options.Show_Subscription}" HorizontalOptions="EndAndExpand"/>
                </StackLayout>
            </StackLayout>

            <StackLayout Orientation="Horizontal" Spacing="0" IsVisible="{Binding ReportMode}">
                <Label Text="Show Direct Costs" Font="{x:Static statics:Fonts.SubTitle}" TextColor="{x:Static statics:Palette.SubTitle}" VerticalOptions="Center" />
                <StackLayout Orientation="Horizontal" Spacing="0" HorizontalOptions="EndAndExpand">
                    <BoxView IsVisible="{Binding GraphMode}" Color="{x:Static statics:Palette.LemongrassGreen}" WidthRequest ="20" HeightRequest="20" VerticalOptions="Center" HorizontalOptions="EndAndExpand"/>
                    <Switch IsToggled="{Binding Options.Show_Direct}" HorizontalOptions="EndAndExpand"/>
                </StackLayout>
            </StackLayout>

For the first of these, its bound field is initially true. In Android it renders as only an "ON" switch (no grey OFF area is visible to its left). It crashes the app with a NRE when you touch operate the funny-looking switch. The second switch is initially false and it both renders and operates fine. On iOS this code is working fine in both cases.

what might cause a switch to render as just an ON with no apparent OFF slide-area available, but only in Android?

I think I'm not alone as I found this recent post on github
https://github.com/xamarin/Xamarin.Forms/issues/3147 (see near the bottom)

I am now on the latest version of XF and all the associated nuget add-ins which the project is using (including appcompat).


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>