Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to display switch in xamarin.forms on android lollipop version? like following image.

$
0
0

I want to display a switch control like that.

but it is not displayed.

please find the my solution

xaml page:
<?xml version="1.0" encoding="utf-8" ?>

<ContentPage.Content>

</StackLayout>

</ContentPage.Content>

customrender page in android:

[assembly: ExportRenderer(typeof(Xamarin.Forms.Switch), typeof(Switch_Render))]
namespace App4.Droid
{
public class Switch_Render: SwitchRenderer
{

   protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Switch> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {                       
                Control.TextOn = "1";
                Control.TextOff = "0";
              }
        }
}

}

The above code is not working in......
In Android version(5.0 or later) the switch is not displayed like this attachment switch.

can any one send the solution how to do it?
please help me.
Thanks in advance.


Viewing all articles
Browse latest Browse all 77050

Trending Articles