5

I have to download some images and videos on the device and I like to track the progress by having a circular ProgressBar in determinate mode in overlay to them.

The problem is that, no matter what, the ProgressBar is still indeterminate.

Is there a way to have it circular and in determinate mode?

Layout

<ProgressBar
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:progressTint="@color/colorPrimary"
                android:indeterminate="false"
                android:max="100"
                android:layout_gravity="center"
                android:id="@+id/message_media_preview_progress"
                android:visibility="gone"
                />

Code

final ProgressBar progressBar = (ProgressBar) mView.findViewById(R.id.message_media_preview_progress);
progressBar.setVisibility(View.VISIBLE);
progressBar.setProgress(0);
storageController.downloadMedia(context, message.getVideoFile(),
        new ProgressListener<Integer>() {
            @Override
            public void onResult(Integer result) {
                progressBar.setProgress(result);
            }
        },
        new ResultListener<Boolean>() {
            @Override
            public void onResult(Boolean result) {
                if(result) {
                    progressBar.setVisibility(View.GONE);
                    setMediaClickListener(message);
                }else{
                    Toast.makeText(context,"Error downloading file",Toast.LENGTH_SHORT).show();
                }
            }
        });
Mahozad
  • 18,032
  • 13
  • 118
  • 133
Jackie Degl'Innocenti
  • 1,251
  • 1
  • 14
  • 34
  • Sorry, it is not possible with stock Android ProgressBar. Look for external libraries: https://github.com/dinuscxj/CircleProgressBar – R. Zagórski Nov 16 '16 at 11:15
  • Ok, good, thank you. If you will put the comment in an answer I will mark it as accepted. – Jackie Degl'Innocenti Nov 16 '16 at 11:22
  • Wrote the answer. – R. Zagórski Nov 16 '16 at 11:31
  • 2
    Does this answer your question? [How do I use Android ProgressBar in determinate mode?](https://stackoverflow.com/questions/2967337/how-do-i-use-android-progressbar-in-determinate-mode) – Mahozad Jan 08 '21 at 10:30
  • Note that despite that duplicate question being about horizontal progress bars, it now has an answer explaining how to do so for circular progress bars as well. – Ryan M Sep 29 '21 at 23:19

3 Answers3

4

Unfortunately, this is not possible with stock Android ProgressBar. Look for external libraries like:

http://github.com/dinuscxj/CircleProgressBar

R. Zagórski
  • 20,020
  • 5
  • 65
  • 90
1

Now it is possible to have determinate circular progress bar in newer versions of material design library:

<com.google.android.material.progressindicator.CircularProgressIndicator
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Refer here for more information.

Mahozad
  • 18,032
  • 13
  • 118
  • 133
0

Change the Progress bar visibility.

  1. Assign the id for the Progress bar.
  2. Progress bar visible - Download button clicked.
  3. Progress bar gone - onResult
Vinay KG
  • 39
  • 1
  • 8