Giter Site home page Giter Site logo

msoftware / loadingbuttonandroid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leandroborgesferreira/loadingbuttonandroid

0.0 3.0 0.0 18.81 MB

A button to substitute the ProgressDialog

License: MIT License

Java 95.98% Shell 0.48% Kotlin 3.54%

loadingbuttonandroid's Introduction

Download Build Status

Progress Button Android

enter image description here

Android Button that morphs into a loading progress bar.

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

You can check how this library was implemented here: https://medium.com/p/9efee6e39711/

Contents

Installation

compile 'br.com.simplepass:loading-button-android:1.6.5'

How to use

Animate and revert animation

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

  <br.com.simplepass.loading_button_lib.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.doneLoagingAnimation(fillColor, bitmap); 
	[or just revert de animation]
	btn.revertAnimation();

- Show 'done' animation

When the loading animation is running, call:

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

- Revert the loading animation with different text or image

circularProgressButton.revertAnimation(new OnAnimationEndListener() {
                @Override
                public void onAnimationEnd() {
                    circularProgressButton.setText("Seu texto aqui!");
                }
            });

or

circularProgressImageButton.revertAnimation(new OnAnimationEndListener() {
        @Override
        public void onAnimationEnd() {
            progressButton.setImageDrawable(R.drawable.image);
        }
    });

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.

Be creative!

You can do a lot of fun stuff with this lib. Check this example:

enter image description here

You can find the code for the animation inside this repo.

Wanna contribute?

If you had some idea for this library and want you contribute, please send me an email: [email protected]

Bugs and Feedback

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

Credits

This libs was inspired in this repo: https://github.com/dmytrodanylyk/android-morphing-button

And that's it! Enjoy!

loadingbuttonandroid's People

Contributors

leandroborgesferreira avatar

Watchers

Michael jentsch avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.