Circular Progress View

An easy to use, and highly customisable progress view, that is circular for Android!

🙈 Gif-shots

​🌶 Want to use it in your project? Here's how to install:

Add the library to the dependencies { ... } section of your app level build.gradle file:

// Check the badge above to replace the version :)
implementation 'com.kishannareshpal:circularprogressview:<version>'

🐌 Now, let's get started

🤡 Custom xml attributes for you!!

Add the view to your xml layout file.

<com.kishannareshpal.circularprogressview.CircularProgressView
        xmlns:cpv="http://schemas.android.com/apk/res-auto"
        android:id="@+id/progress"
        android:layout_width="48dp"
        android:layout_height="48dp"
        cpv:progressType="determinate"
        cpv:progressStrokeColor="@color/blue" />

* It is required when you set either determinateProgressValue or determinateProgressValuePercentage.

🥢 Methods:

🏃🏾‍♂️ Lets see it in action

CircularProgressView cpv = findViewById(R.id.cpv);
// You can color the background, the stroke or the border.
// Multiple colors for gradient.
int[] gradientColors = new int[] {
    Color.parseColor("#ff9100"), // orange
    Color.parseColor("#ff1744") // red
};

cpv.setBackgroundColor(Color.parseColor("#ffcdd2")); // light red
cpv.setBorderColor(Color.parseColor("#ffebee")); // lighter red
cpv.setProgressStrokeColor(gradientColors); // a gradient of red and orange

// Or pass just a single color for a solid progressStrokeColor.
/* cpv.setProgressStrokeColor(Color.parseColor("#ff1744")); */
// Choose where the progressStroke should be positioned:
cpv.setStrokePlacement(StrokePlacement.OUTSIDE);
/* cpv.setStrokePlacement(StrokePlacement.CENTER); */
/* cpv.setStrokePlacement(StrokePlacement.INSIDE); */
// Lets suppose you are downloading a file, and you want to show a progress:
cpv.setProgressType(ProgressType.DETERMINATE)

int totalBytes = 349022; // the maximum value of the progress
cpv.setRange(totalBytes);

// Update the progress using:
cpv.setProgress(10.0f, true) // 10% of the maximum value of the progress.

// Or if you want to update the progress using a value out of total.
int downloadedBytes = 1230; // downloaded 1230 bytes out of the total of 349022;
int p = CircularProgressView.calcProgressValuePercentageOf(downloadedBytes, totalBytes)
cpv.setProgress(p, true);

Last updated