An Android Material Design button with a built-in loading/progress state. Perfect for showing in-progress feedback on actions like form submission, sign-in, and API calls without building a custom layout.
- Built-in progress indicator — a loading spinner that appears inside the button while work is happening.
- Fully customizable — set text, corner radius, and colors to match your app.
- Ripple + state backgrounds — Material-compatible touch feedback and pressed/disabled states.
- Lightweight — a single custom
View(extendsRelativeLayout), no external UI framework required. - Kotlin + AndroidX — modern, minimal dependencies (
appcompat,core-ktx,material).
Add the dependency to your module's build.gradle:
dependencies {
implementation 'com.github.anangkur:Material-Loading-Button:<version>'
}Published distribution is via JitPack (see the release tags on GitHub for available versions).
Add the button to your XML layout:
<com.anangkur.materialloadingbutton.MaterialLoadingButton
android:id="@+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:text="Submit"
app:radius="8dp" />val button = findViewById<MaterialLoadingButton>(R.id.btnSubmit)
// Show the loading spinner (e.g. before an async call)
button.showProgress()
// ... do async work ...
// Hide the spinner and return to normal state
button.hideProgress()
// Set / update the button label
button.setText("Retry")| Method | Description |
|---|---|
showProgress() |
Show the built-in loading spinner. |
hideProgress() |
Hide the loading spinner. |
setText(text: String) |
Update the button label. |
setRadius(radius: Float) |
Adjust the corner radius of the button background. |
| Attribute | Type | Description |
|---|---|---|
app:text |
string | The button label. |
app:radius |
dimension | Corner radius of the button background. |
| (color/background attributes) | — | Inherits appcompat/material theming for colors and ripple. |
MaterialLoadingButton extends RelativeLayout and inflates the loading_button layout, which composes a TextView (the label) and a ProgressBar (the spinner). Ripple, state-list, and gradient drawables are generated programmatically in setupBackground(), so the button responds correctly to touch and disabled states while supporting API 16+.
- minSdk 16
- compileSdk 34
- Kotlin (JVM target 11)
- AndroidX (
android.useAndroidX=true)
The reusable library source lives in the materialloadingbutton/ module (an android-library), while app/ is a demo app showing usage.
- Fork the repository.
- Create your feature branch:
git checkout -b feature/AmazingFeature. - Commit your changes:
git commit -m 'Add some AmazingFeature'. - Push to the branch:
git push origin feature/AmazingFeature. - Open a Pull Request.
Distributed under the MIT License. See LICENSE for more information.
Anang Kurniawan — @anang_kur · anangk97@gmail.com