Reputation: 1261
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();
}
}
});
Upvotes: 5
Views: 3250
Reputation: 24472
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.
Upvotes: 1
Reputation: 20258
Unfortunately, this is not possible with stock Android ProgressBar. Look for external libraries like:
http://github.com/dinuscxj/CircleProgressBar
Upvotes: 4
Reputation: 39
Change the Progress bar visibility.
Upvotes: 0