2013-06-20 71 views
1

想要使用像谷歌Play商店进度条。ProgressBar:不确定+显示进度(如谷歌Play商店)

首先它(进度条)是不确定的 - 它显示为一个不断移动的加载。然后它显示进度 - 从0到100

在我的情况下,栏只显示不确定或进度 - 取决于xml-config。 有什么建议吗?

我的进度条: 这里的酒吧显示短时间内移动的负载。当下载开始时进度条自己消失了。 没有android:indeterminate =“true”没有不确定性,只显示进度条。 Progress我更改progress.setProgress((int)_self.currentProgress);

<ProgressBar 
       android:id="@+id/progress" 
       android:indeterminate="true" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:layout_marginTop="5dip" 
       style="@style/ProgressBarHoloHorizontal"/> 

风格:

<style name="ProgressBarHoloHorizontal"> 
    <item name="android:indeterminateOnly">false</item> 
    <item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal_holo</item> 
    <item name="android:minHeight">16dip</item> 
    <item name="android:maxHeight">16dip</item> 
    <item name="android:progressDrawable">@drawable/progress_horizontal_holo_light</item> 
</style> 
+2

当你设置你的进度进度不确定状态应该dissapear,如果不只需输入'progress.setIndeterminate(false);'当你得到你的第一个进展。 – zozelfelfo

+0

谢谢,@zozelfelfo!正确的解决方案 – vsvydenko

回答

1

使用progress.setIndeterminate(假)从不确定变为确定进度条

+0

如前所述(请参阅@zozelfelfo评论)progress.setIndeterminate(false)应该添加到位,当您获得第一个进度 – vsvydenko