Circular Loading Button – Library

Published by Kapil Mohan on

Android Button that morphs into a loading progress bar. Useful for login or form button animation.

Github Link:- https://github.com/leandroBorgesFerreira/LoadingButtonAndroid

Include above code instead of android Button.

Steps:

  • Instantiate the button.
  • Call startAnimation() before starting background process.
  • Call revertAnimation() to switch back to default state. called after completing background process.

Switch to determinant progress

You can switch between indeterminant and determinant progress:

– Show ‘done’ animation

When the loading animation is running, call:

– Revert the loading animation with different text or image

or

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.

Example for using Rounded button

XML

Example uses a button background for rounded corner and gradient background. If you need same , create login background file in drawable and add the following code.

login_button_bk.xml

Java

Oncompletion

Library Details:-

Credits:

Official GitHub repo.


Kapil Mohan

Like to add color to developers life and apps. Can create smile using Android, iOS, PHP, codeignitor, web technologies, etc... Feel free to contact me at [email protected] .