Hai,
I am new xamarin.forms.
I was write the code xaml page like
<switch x:Name="Switch1" HorizontalOptions="Center AndExapand" VerticalOptions="CenterAndExpand"/>
In Android -Switch Render is
[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";
Android.Graphics.Color colorOn = Android.Graphics.Color.Green;
Android.Graphics.Color colorOff = Android.Graphics.Color.Gray;
Android.Graphics.Color colorDisabled = Android.Graphics.Color.Gray;
StateListDrawable drawable = new StateListDrawable();
drawable.AddState(new int[] { Android.Resource.Attribute.StateChecked }, new ColorDrawable(colorOn));
drawable.AddState(new int[] { -Android.Resource.Attribute.StateEnabled }, new ColorDrawable(colorDisabled));
drawable.AddState(new int[] { }, new ColorDrawable(colorOff));
Control.ThumbDrawable = drawable;
}
}
}
}
In my company I am using visual studio.
I am working under xamarin.forms
By using above code ,the values of 1 and 0 are display on android versions of kitkat,jeallybean.
but i andorid version of lollipop, the values of 1 and 0 are not displayed .
why ?
can any one help me please.
please post your solution.