This is a Xamarin Android Binding for the SwitchButton.
This project provides you a convenient way to use and customise a SwitchButton widget in Android. With just resources changed and attrs set, you can create a lifelike SwitchButton of Android 5.0+, iOS, MIUI, or Flyme and so on.
Install NuGet package.
Define xmlns:app
in your root view.
xmlns:sw="http://schemas.android.com/apk/res-auto"
Add the SwitchButton
to your layout:
<com.kyleduo.switchbutton.SwitchButton
android:id="@+id/sw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
sw:kswThumbColor="@color/white"
sw:kswThumbMargin="6dp"/>
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
_switch = FindViewById<SwitchButton>(Resource.Id.sw);
_switch.CheckedChange += (sender, e) => Toast.MakeText(this, $"isChecked {e.IsChecked}", ToastLength.Short).Show();
}
Run and play with the sample.