Progress Button for Xamarin.Android - Ported from this library
Article on ProAndroidDev.com explaining how it works (in kotlin): here
- No layout changes required
- Few lines of code to add
- Easily configurable
- Customizable
- Built in fade animations
Install-Package Ir.XamarinDev.Android.ProgressButton protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); var myButton = FindViewById<MaterialButton>(Resource.Id.myButton); // bind your button to activity lifecycle this.BindProgressButton(myButton); // (Optional) Enable fade in/out animations myButton.AttachTextChangeAnimator(); // Show progress with "Loading" text myButton.ShowProgress((progressParams) => { progressParams.ButtonTextRes = Resource.String.loading; progressParams.ProgressColor = Color.White; }); // Hide progress and show "Submit" text instead myButton.HideProgress(Resource.String.submit); }var animatedDrawable = ContextCompat.GetDrawable(this, Resource.Drawable.animated_check); // Defined bounds are required for your drawable animatedDrawable.Bounds = new Rect(0, 0, 40, 40); button.ShowDrawable(animatedDrawable, (drawableParams) => { buttonTextRes = Resource.String.saved; });Detailed doc: here
To avoid memory leaks you always need to bind your button to a LifecycleOwner (usually Activity, or Fragment):
[ILifecycleOwner].BindProgressButton(button);GPL v3.0
XamarinDev
Anton Hadutski - GitHub



