如何显示水平的Android不确定进度条 [英] How to show a Horizontal Android Indeterminate Progress Bar
问题描述
如何在android中显示不确定的水平进度条?进度栏的动画应从0开始到100,然后从100连续回到0.我不是在寻找方向盘进度条.
How to show an indeterminate horizontal progress bar in android? The animation of 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.原始可绘制对象位于frameworks/base/core/res/res/drawable
下.将它们复制到您的项目中,然后根据需要更改颜色.
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屋!