如何使ProgressBar处于圆形并处于确定模式? [英] How to have a ProgressBar circular and in determinate mode?
本文介绍了如何使ProgressBar处于圆形并处于确定模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须在设备上下载一些图像和视频,我想通过在确定的模式下将圆形的ProgressBar叠加在其上来跟踪进度.
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.
问题在于,无论如何,ProgressBar仍不确定.
The problem is that, no matter what, the ProgressBar is still indeterminate.
是否有办法使它呈圆形并处于确定模式?
Is there a way to have it circular and in determinate mode?
布局
<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"
/>
代码
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();
}
}
});
推荐答案
不幸的是,这无法通过现有的Android ProgressBar实现.查找类似以下的外部库:
Unfortunately, this is not possible with stock Android ProgressBar. Look for external libraries like:
http://github.com/dinuscxj/CircleProgressBar
这篇关于如何使ProgressBar处于圆形并处于确定模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文