Android的不确定的进度栏不确定、进度、Android

2023-09-05 23:06:20 作者:︾我该怎样诠释你给的伤、

如何获得在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.