如何在Android中使水平进度条取决于秒?
我想知道如何使水平进度条取决于秒。例如,我必须向进度条写入哪些代码,该代码在 0 秒时从 0% 开始,并在 60 秒后达到 100%?
继续我想制作一个仅取决于秒而不取决于其他的水平进度条。
I want to know how to make an horizontal progress bar depend on seconds. For example, what code I have to write to the progress bar start in 0% at 0 seconds and reach 100% after 60 seconds?
Resuming I want to make an horizontal progress bar that only depends on seconds and nothing else.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个答案是根据上面的答案修改的。
This answer is modified from above answer.
我假设您有一些代码已经数到 60。基于此:
I'm assuming you have some code that is counting to 60 already. Based on that:
我已经编辑了代码。现在就看吧。这是如何运作的。首先,您在进度条上设置总计,在您的情况下为 60。然后您需要计算自开始以来已经过去了多少时间的百分比以及使用 timePassed/60*100 获得的百分比并将其转换为 int。因此,每次勾选时,您都会将进度增加总大小的 1/100。
希望这能让它更清楚。
i have edited the code. see it now. so how this works. first you set a total on the progress bar which in your case will be 60. then you need to calculate the percentage of how much time has passed since the start and that you get with timePassed/60*100 and casting it to int. so on every tick you increase the progress by 1/100 of the total size.
Hope this makes it more clear.