Android的不确定的进度栏 [英] Android indeterminate progress bar

查看:150
本文介绍了Android的不确定的进度栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得在Android的不确定水平进度条?进度条应该开始从0到100,然后返回从100到0连续进行。我不是在寻找车轮进度条。

How to get an indeterminate horizontal progress bar in android ? The progress bar should start from 0 to 100 and then go back from 100 to 0 continuously. I am not looking for the wheel progress bar.

推荐答案

我已经知道 setIndeterminate 将给予无限的水平进度条。但是这将是相似的装载轮,所不同的是这将是水平的。如果你看到我的问题,我一直在寻找它从0开始,去一路100(逐渐增加),单杠。如果要实现这一点在Android中,你必须使用你的进度条,如下:

I already knew that setIndeterminate will give an infinite horizontal progress bar. But it will be similar to the loading wheel, except that it will be horizontal. If you see my question I was looking for horizontal bar which starts from 0 and goes all the way to 100 (a gradual increase). If you want to achieve this in Android, you must use your progress bar as below:

 <ProgressBar
    android:id="@+id/progress_horizontal"
    android:indeterminateOnly="false"
    android:indeterminateDrawable="@drawable/progress_indeterminate_horizontal"
    android:progressDrawable="@drawable/progress_horizontal"
    android:minHeight="24dip"
    android:maxHeight="24dip" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>

因为我想改变我的进度条的背景下,我改变了ProgressDrawable和IndeterminateDrawable。原来可绘制都位于框架/基/核心/ RES / RES /绘制。根据您的需要将它们复制到您的项目,改变颜色。

As I wanted to change the background of my progress bar, I changed the ProgressDrawable and IndeterminateDrawable. The original drawables are located under frameworks/base/core/res/res/drawable. Copy them to your project and change the color according to your needs.

创建一个线程,更新进度计数和做了 Thread.sleep代码。然后将消息发送到将更新UI线程进度条的处理程序。

Create a thread which updates the progress count and does a Thread.Sleep. Then it sends the message to the Handler which will update the progress bar in UI thread.

这篇关于Android的不确定的进度栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆