如何创建“横向风格” Android 中以编程方式显示进度条?

发布于 2024-12-24 16:40:12 字数 164 浏览 3 评论 0原文

我正在以编程方式在我的应用程序中创建一个 ProgressBar,默认情况下它是 SPIN 样式,但我希望它是 HORIZONTAL 样式。我没有看到任何方法/常量来实现这一点。

我不想使用 ProgressDialog,因为它与我的应用程序 UI 主题不一致。

请问有什么建议吗?

I am creating a ProgressBar in my app programmatically it is of SPIN style by default however I want it in HORIZONTAL style. I don't see any method/constant to achieve this.

And I don't want to use ProgressDialog as it'd be inconsistent with my App UI theme.

Any suggestions please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

零崎曲识 2024-12-31 16:40:12

使用这个:

ProgressBar pb = new ProgressBar(context,
                                 null, 
                                 android.R.attr.progressBarStyleHorizontal);

use this:

ProgressBar pb = new ProgressBar(context,
                                 null, 
                                 android.R.attr.progressBarStyleHorizontal);
や莫失莫忘 2024-12-31 16:40:12

如果您使用的是 ProgressDialog,那么这里有一种更改 ProgressDialog 中进度条样式的方法。

mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

If you are using a ProgressDialog then, here is a way to change the style of the progressBar in the ProgressDialog.

mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文