如何显示水平 Android 不确定进度条
如何在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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我已经知道
setInminateate
会给出一个无限的水平进度条。但它与装载轮类似,只是它是水平的。如果你看到我的问题,我正在寻找从 0 开始一直到 100(逐渐增加)的水平条。如果你想在Android中实现这一点,你必须使用你的进度条,如下所示:由于我想改变我的进度条的背景,我改变了ProgressDrawable和InminatedDrawable。原始的可绘制对象位于
frameworks/base/core/res/res/drawable
下。将它们复制到您的项目中并根据您的需要更改颜色。创建一个更新进度计数并执行 Thread.Sleep 的线程。然后它将消息发送到 Handler,该 Handler 将更新 UI 线程中的进度条。
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: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.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.使用 ProgressBar 的 setInminateate 方法:
但是,是的,您可以在开发人员文档中很快找到它。
http://developer.android.com/reference/android /widget/ProgressBar.html#setInminated%28boolean%29
Use the method setIndeterminate of ProgressBar:
But yeah, you could have found this pretty quickly in the developer docs.
http://developer.android.com/reference/android/widget/ProgressBar.html#setIndeterminate%28boolean%29
也许有点晚了,但你可以做这样的事情:
希望它能帮助别人!
Maybe a bit late, but you can do something like this:
Hope it helps someone!
为了扩展 Vinoth 答案,这里有一个现成的代码:
To expand on Vinoth Answer, here is a ready code:
在定义进度条的 xml 中,您可以添加
In the xml defining your progress bar, you can add