Introduction

In this article, we are going to see how to create a Circular Progress Bar in Android app using the Android Studio. It will show the current status of the process; i.e., percentage completed. There are many types of circular progress bars with different colors.
Step 1
Create a new project in Android Studio.
Android
Give a name to the project and click "Next".
Android
Select the "Phone and Tablet" and click "Next".
Android
Select an empty activity and click "Next".
Android
At last, give the activity name and click on "Finish".
Android
Step 2
Set up the gradle by just locating the Gradle Scripts>>Build.Gradle 1
Android
And type the following dependency in your app's build.gradle.
Android
Code copy is here
  1. maven{
  2. url "https://jitpack.io"}
Step 3
Locate the Gradle Scripts>>Build. Gradle 2
Android
And type the following dependency in your app's build.gradle.
Android
Code copy is here
  1. compile 'br.com.simplepass:loading-button-android:1.7.2'
Step 4
Next, go to app >> res >>Styles and
Android
Just type the code as follows.
Android
Code copy is here
  1. <resources>
  2. <!-- Base application theme. -->
  3. <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
  4. <!-- Customize your theme here. -->
  5. <item name="colorPrimary">@color/colorPrimary</item>
  6. <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
  7. <item name="colorAccent">@color/colorAccent</item>
  8. </style>
  9. </resources>
Step 5
Next, go to app >> res >> layout >> activity_main.xml. Select activity page
Android
And just type the code as follows.
Android
Code copy is here,
  1. <RelativeLayout
  2. xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent"
  7. tools:context="com.example.hari.circularprocessbar.MainActivity">
  8. <br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
  9. android:id="@+id/btndown"
  10. android:text="Downloaad"
  11. android:textColor="@android:color/white"
  12. android:layout_centerInParent="true"
  13. android:layout_width="match_parent"
  14. android:layout_height="wrap_content"
  15. android:background="@drawable/shape_default"
  16. app:spinning_bar_color="#FFF"
  17. app:spinning_bar_padding="6dp"
  18. app:spinning_bar_width="4dp"/>
  19. </RelativeLayout>
Step 6
Next, go to app >> java>>Mainactivity.java. Select Mainactivity page:
Android
And just type the code as follows:
Android
Code copy is here
  1. package com.example.hari.circularprocessbar;
  2. import android.graphics.BitmapFactory;
  3. import android.graphics.Color;
  4. import android.os.AsyncTask;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.widget.Toast;
  9. import br.com.simplepass.loading_button_lib.customViews.CircularProgressButton;
  10. public class MainActivity extends AppCompatActivity {
  11. CircularProgressButton circularProgressButton;
  12. @Override
  13. protected void onCreate(Bundle savedInstanceState) {
  14. super.onCreate(savedInstanceState);
  15. setContentView(R.layout.activity_main);
  16. circularProgressButton = (CircularProgressButton)findViewById(R.id.btndown);
  17. circularProgressButton.setOnClickListener(new View.OnClickListener() {
  18. @Override
  19. public void onClick(View view) {
  20. final AsyncTask<String,String,String> demoDownload = new AsyncTask<String, String, String>() {
  21. @Override
  22. protected String doInBackground(String... strings) {
  23. try{
  24. Thread.sleep(3000);
  25. } catch (InterruptedException e){
  26. e.printStackTrace();
  27. }
  28. return "done";
  29. }
  30. @Override
  31. protected void onPostExecute(String s){
  32. if(s.equals("done"))
  33. {
  34. Toast.makeText(MainActivity.this,"Download done",Toast.LENGTH_SHORT).show();
  35. circularProgressButton.doneLoadingAnimation(Color.parseColor("#333639"), BitmapFactory.decodeResource(getResources(),R.drawable.ic_done_white_48dp));
  36. circularProgressButton.startAnimation();
  37. demoDownload.execute();
  38. }
  39. }
  40. }
  41. }
  42. });
  43. }
  44. }
Step 7
After step 4, Sync all the dependency gradles and Mainactivity.java resource files by clicking the Sync button on the top right corner of the gradle page.
Android
Step 8
Verify the preview.
Android
->After the code is applied, the preview will appear like this.
Step 9
Next, go to Android Studio and deploy the application. Select an Emulator or your Android mobile with USB debugging enabled. Give it a few seconds to make installations and set permissions.
Android
Run the application in your desired emulator (Shift + F10).
Android
Explanation of source code
The source code provided in this article is just the dependencies of motions and the code used in activity_main.xml will make the circular progress bar appear and define its attributes.

Summary

In this article, we created the app named circular process Bar, then we have inserted a Gradle and we learned how to use the circular process Bar and Finally, we have deployed that as an output.
*Support and Share, Thank You*