A button to substitute the ProgressDialog.

Overview

Progress Button Android

Preview

Android Button that morphs into a loading progress bar.

  • Fully customizable in the XML
  • Really simple to use.
  • Makes your app looks cooler ;)

Contents

Installation

Set up the dependency

  1. Add the mavenCentral() repository to your root build.gradle at the end of repositories:
allprojects {
	repositories {
		...
		mavenCentral()
	}
}
  1. Add the LoadingButton dependency in the build.gradle:
implementation group: 'com.apachat', name: 'loadingbutton-android', version: '1.0.11'

Badge:

Maven Central

How to use

Animate and revert animation

Add the button in your layout file and customize it the way you like it.

<com.apachat.loadingbutton.core.customViews.CircularProgressButton
	android:id="@+id/btn_id"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:background="@drawable/circular_border_shape" />
	app:spinning_bar_width="4dp" <!-- Optional -->
	app:spinning_bar_color="#FFF" <!-- Optional -->
	app:spinning_bar_padding="6dp" <!-- Optional -->

Then, instanciate the button

CircularProgressButton btn = (CircularProgressButton) findViewById(R.id.btn_id)
btn.startAnimation();

//[do some async task. When it finishes]
//You can choose the color and the image after the loading is finished
btn.doneLoadingAnimation(fillColor, bitmap);

//[or just revert de animation]
btn.revertAnimation();

You can also add a callback to trigger an action after the startAnimation has finished resizing the button :

btn.startAnimation {
	<start async task>
}

Switch to determinant progress

You can switch between indeterminant and determinant progress:

circularProgressButton.setProgress(10)
...
circularProgressButton.setProgress(50)
...
circularProgressButton.setProgress(100)

- Show 'done' animation

When the loading animation is running, call:

//Choose the color and the image that will be show
circularProgressButton.doneLoadingAnimation(fillColor, bitmap);

- Revert the loading animation with different text or image

progressButton.revertAnimation {
	progressButton.text = "Some new text"
}

or

progressImageButton.revertAnimation {
	progressImageButton.setImageResource(R.drawable.image)
}

- Button State

This button is a state machine and it changes its state during the animation process. The states are:

Before Draw

This state is the initial one, the button is in this state before the View is draw on the screen. This is the state when the button is accesed in the onCreate() of an Activity.

Idle

After the button is drawn in the screen, it gets in the Idle state. It is basically waiting for an animation. Call startAnimation() to start animations with this button.

WAITING_PROGRESS

If the startAnimation() is called before the Idle state, the button goes to this state. The button waits for the button to be drawn in the screen before start the morph animation.

MORPHING

The button stays in this state during the morphing animation.

PROGRESS

After the morph animation, the button start the progress animation. From this state the done and revert animations can happen.

MORPHING_REVERT

The button stays in this state during the morphing animation reversal.

WAITING_DONE

If the doneLoadingAnimation(fillColor: Int, bitmap: Bitmap) is called when the button is still morphing, it enter in this state. The button waits for the morph animation to complete and then start the done animation.

DONE

The button enters this state when the doneLoadingAnimation finishes.

WAITING_TO_STOP

The button enters this state when the stopAnimation() is called before the morph state is completed. The button waits for the morph animation to complete and the stops further animations.

STOPPED

The button enters this state after stopAnimation() when the button is not morphing.

Configure XML

  • app:spinning_bar_width : Changes the width of the spinning bar inside the button
  • app:spinning_bar_color: Changes the color of the spinning bar inside the button
  • app:spinning_bar_padding: Changes the padding of the spinning bar in relation of the button bounds.
  • app:initialCornerAngle: The initial corner angle of the animation. Insert 0 if you have a square button.
  • app:finalCornerAngle: The final corner angle of the animation.

Problems and troubleshooting

Animation

This library only works with selector as the background, but not with shape as the root tag. Please put your shape inside a selector, like this:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:state_selected="false">
    <shape android:shape="rectangle">
        <corners android:radius="10dp" />
        <solid android:color="@android:color/transparent" />
        <stroke android:width="3dp"
            android:color="@color/black"/>
    </shape>
</item>
</selector>

I still need to debug this problem.

Manifest merge

This library only supports androidx since prior the version 2.0.0. So don't try to use it with the old Support Library. Use androidx instead.

Bugs and Feedback

For bugs, feature requests, and discussion please use GitHub Issues.

And that's it! Enjoy!

You might also like...
Android button which moves in eight direction.
Android button which moves in eight direction.

Moving Button Android button which moves in eight direction. Preview Sample Demo You can download demo movie file here : demo.mov It's also on Youtube

Button for android with animations for transition and error states.
Button for android with animations for transition and error states.

Transition Button Android Preview Expand animation: Shake animation: Installation Gradle dependencies { implementation 'com.royrodriguez:transitionbu

[] Android floating action button
[] Android floating action button

DEPRECATED Use the FloatingActionButton from the support library instead. FloatingActionButton Description Android floating action button which reacts

Floating Action Button for Android based on Material Design specification
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

A loading animation based on Floating Action Button
A loading animation based on Floating Action Button

FAB-Loading A loading animation based on Floating Action Button. Usage Include the LoadingView widget in your view: io.saeid.fabloading.LoadingView

Android library that provides the floating action button to sheet transition from Google's Material Design.
Android library that provides the floating action button to sheet transition from Google's Material Design.

MaterialSheetFab Library that implements the floating action button to sheet transition from Google's Material Design documentation. It can be used wi

A Toggling Add/Remove button

Cross View Add a CrossView to your layout cdflynn.android.library.crossview.CrossView android:id="@+id/sample_cross_view" android

Android Swipeable button like in iOS unlock screen. Made by Stfalcon
Android Swipeable button like in iOS unlock screen. Made by Stfalcon

swipeable-button Who we are Need iOS and Android apps, MVP development or prototyping? Contact us via [email protected]. We develop software since 200

Android library to animate Floating Action Button to Bottom Sheet Dialog and vice-versa
Android library to animate Floating Action Button to Bottom Sheet Dialog and vice-versa

FabulousFilter Show some ❤️ and star the repo to support the project This library is the implementation of filter-concept posted on MaterialUp.com. It

Support Floating Action Button transformation for Android
Support Floating Action Button transformation for Android

Fab Transformation This library supports Floating Action Button transformation in Material Design Guideline. Screenshot Sample App Installation Add th

Android Library To Create Button With Multi Reactions like Facebook or Linkedin
Android Library To Create Button With Multi Reactions like Facebook or Linkedin

ReactButton Android Library written in Java to Create ReactButton with Multi Reactions like Facebook or Linkedin 😎 Default Reactions 😄 Custom Reacti

A cute widget of Switch Button for  you to create beautiful and friendly UI.
A cute widget of Switch Button for you to create beautiful and friendly UI.

SwitchButton To get a quick preview, you can get Demo apk in Google Play or Directly download. This project provides you a convenient way to use and c

A simple Floating Action Button that shows an anchored Navigation View
A simple Floating Action Button that shows an anchored Navigation View

Floating Navigation View A simple Floating Action Button that shows an anchored Navigation View and was inspired by Menu Material Fixed created by Tom

A download button with pretty cool animation
A download button with pretty cool animation

ArrowDownloadButton A download button with pretty cool animation, this is an implemention of https://dribbble.com/shots/2012292-Download-Animation Enj

Button which is visible while user holds it. Main use case is controlling audio recording state (like in Telegram, Viber, VK).
Button which is visible while user holds it. Main use case is controlling audio recording state (like in Telegram, Viber, VK).

HoldingButton Button which is visible while user holds it. Main use case is controlling audio recording state (like in Telegram, Viber, VK). Getting s

[] An Android library for an expandable button menu
[] An Android library for an expandable button menu

ExpandableButtonMenu ExpandableButtonMenu is an Android library which implements an expandable button that can be used as a substitute of a fixed size

This is a Material Design loading button

This is a library project with a custom view that implements concept of Send Comment (https://dribbble.com/shots/1986254-Send-Comment-Shoppr) made by

comtomize view submit button which you use for submit operation or download operation and so on.
comtomize view submit button which you use for submit operation or download operation and so on.

This is library project with a custom view that implements concept of Submit Button (https://dribbble.com/shots/1426764-Submit-Button?list=likes&offse

Floating Action Button for Android based on Material Design specification
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Comments
  • Missing round corners of custom shape by revertAnimation

    Missing round corners of custom shape by revertAnimation

    Hi, in implementation 'com.apachat:loadingbutton-android:1.0.11' on Android 11

    <com.apachat.loadingbutton.core.customViews.CircularProgressButton
                    android:id="@+id/btn_login"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/login_btn_login"
                    android:background="@drawable/shape_button_primary"
                    android:theme="@style/Button.Primary"
                    android:stateListAnimator="@null"
                    app:spinning_bar_color="@color/verticalBarPrimary"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="12dp"/>
    
    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="@color/primary" />
        <corners android:radius="11dp" />
    </shape>
    

    while calling revertAnimation the round corners are gone i.e. become squared. Any ideas?

    opened by vicmosin 0
Releases(1.0.11)
Owner
Farham Hosseini
Calm, creative and forward-thinking
Farham Hosseini
A loading animation based on Floating Action Button

FAB-Loading A loading animation based on Floating Action Button. Usage Include the LoadingView widget in your view: <io.saeid.fabloading.LoadingView

Saeed Masoumi 689 Oct 14, 2022
Android - An action bar item which acts both as a refresh button and as a progress indicator

RefreshActionItem An action bar item that implements this common pattern: Initially it shows a refresh button. If the button is clicked, a background

Manuel Peinado Gallego 655 Nov 10, 2022
Progress Button is a android library for hanling different types state like active, finished, enabled, disabled and reset with a single line of code.

Progress Button is a android library for hanling different types state like active, finished, enabled, disabled and reset with a single line of code.

Sagar Khurana 38 Nov 15, 2022
ProgressDialog that waits a minimum time to be dismissed before showing. Once visible, the ProgressDialog will be visible for a minimum amount of time to avoid "flashes" in the UI.

DelayedProgress ProgressBar and ProgressDialog that waits a minimum time to be dismissed before showing. Once visible, the they will be visible for a

Said Tahsin Dane 95 Nov 25, 2022
Base on android-process-button this is the advanced version of the android-process-button.

Rock Button release log Base on android-process-button this is the advanced version of the android-process-button ##Main Features ActionProcessButton

MDCCLXXVI KPT 119 Nov 25, 2022
A simple Floating Action Button that shows an anchored Navigation View

Floating Navigation View A simple Floating Action Button that shows an anchored Navigation View and was inspired by Menu Material Fixed created by Tom

André Mion 1.3k Dec 29, 2022
A layout to transition between two views using a Floating Action Button as shown in many Material Design concepts

⚠ This library is no longer maintained ⚠️ FABRevealLayout A layout to transition between two views using a Floating Action Button as shown in many Mat

Tomás Ruiz-López 901 Dec 9, 2022
Android Circular Progress Button

?? Before using this library, read information below ?? This library is not more supported. If you want to add new feature or fix a bug, grab source

Dmytro Danylyk 5.6k Jan 7, 2023
Circle button widget for Android

DEPRECATED This library is deprecated and no new development is taking place. Consider using a FAB(Floating action button) instead. E.g. the Android D

Markus Hintersteiner 1.5k Dec 9, 2022
FButton - a flat button library for Android

FButton FButton is a custom Button of Android with "Flat UI" concept. FButton's design get inspiration from designmono. This library is very small and

Le Van Hoang 1.4k Dec 12, 2022