How to have a ProgressBar circular and in determinate mode?

≡放荡痞女 提交于 2019-11-30 17:39:08

问题


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

回答1:


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

http://github.com/dinuscxj/CircleProgressBar




回答2:


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


来源:https://stackoverflow.com/questions/40630549/how-to-have-a-progressbar-circular-and-in-determinate-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!