Skip to content

Commit 1ec71d6

Browse files
Add README.md
1 parent 387cc49 commit 1ec71d6

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Progress Button for Xamarin.Android - Ported from [this](https://github.com/razir/ProgressButton) library
2+
[![Release](https://img.shields.io/github/v/release/XamarinDeveloper/ProgressButton?color=FC0&display_name=tag&label=Release)](https://github.com/XamarinDeveloper/ProgressButton/releases)
3+
[![NuGet](https://img.shields.io/nuget/v/Ir.XamarinDev.Android.ProgressButton?label=NuGet)](https://www.nuget.org/packages/Ir.XamarinDev.Android.ProgressButton/)
4+
5+
![basic progress button example](https://raw.githubusercontent.com/XamarinDeveloper/ProgressButton/main/Assets/ProgressEnd.gif)
6+
7+
![progress cebter button example](https://raw.githubusercontent.com/XamarinDeveloper/ProgressButton/main/Assets/ProgressCenter.gif)
8+
9+
![mixed progress button example](https://raw.githubusercontent.com/XamarinDeveloper/ProgressButton/main/Assets/MixedBehaviour.gif)
10+
11+
#### Article on ProAndroidDev.com explaining how it works (in kotlin) : [here](https://proandroiddev.com/replace-progressdialog-with-a-progress-button-in-your-app-14ed1d50b44)
12+
13+
14+
#### Add progress animation to any button by adding a few lines of code without layout changes
15+
16+
### Main features:
17+
- No layout changes required
18+
- Few lines of code to add
19+
- Easily configurable
20+
- Customizable
21+
- Built in fade animations
22+
23+
## NuGet package
24+
```
25+
Install-Package Ir.XamarinDev.Android.ProgressButton
26+
```
27+
28+
## How to use
29+
30+
### Basic example
31+
32+
```C#
33+
protected override void OnCreate(Bundle savedInstanceState) {
34+
base.OnCreate(savedInstanceState);
35+
SetContentView(Resource.Layout.activity_main);
36+
37+
var myButton = FindViewById<MaterialButton>(Resource.Id.myButton);
38+
39+
// bind your button to activity lifecycle
40+
this.BindProgressButton(myButton)
41+
42+
// (Optional) Enable fade in/out animations
43+
myButton.AttachTextChangeAnimator()
44+
45+
// Show progress with "Loading" text
46+
myButton.ShowProgress((progressParams) => {
47+
progressParams.ButtonTextRes = Resource.String.loading;
48+
progressParams.ProgressColor = Color.White;
49+
});
50+
51+
// Hide progress and show "Submit" text instead
52+
myButton.HideProgress(Resource.String.submit)
53+
}
54+
```
55+
56+
### Showing AnimatedDrawable
57+
58+
![animated drawable button example](https://raw.githubusercontent.com/XamarinDeveloper/ProgressButton/main/Assets/AnimatedDrawable.gif)
59+
60+
```C#
61+
var animatedDrawable = ContextCompat.GetDrawable(this, Resource.Drawable.animated_check);
62+
// Defined bounds are required for your drawable
63+
animatedDrawable.Bounds = new Rect(0, 0, 40, 40);
64+
65+
button.ShowDrawable(animatedDrawable, (drawableParams) => {
66+
buttonTextRes = Resource.String.saved;
67+
});
68+
```
69+
70+
### Detailed doc: [here](DetailedDoc.md)
71+
72+
### Avoiding memory leaks
73+
To avoid memory leaks you always need to bind your button to a LifecycleOwner (usually Activity, or Fragment):
74+
75+
```C#
76+
[ILifecycleOwner].BindProgressButton(button)
77+
```
78+
79+
### Author
80+
XamarinDev
81+
82+
### Credits
83+
Anton Hadutski - [GitHub](https://github.com/razir)

0 commit comments

Comments
 (0)