+1 vote
in Other by
Is there any possibility to show a spinning progress bar in a button? e.g. as background drawable?

JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I was having the same problem, so I created a specialized button for this: LoadingProgressButton

Include the button like this:

    <br.com.simplepass.loading_button_lib.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 -->

And use it like this:

    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();
...