java 如何展示全息主题的活动圈?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12316365/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 08:25:07  来源:igfitidea点击:

How can I display a holo-themed activity circle?

javaandroidandroid-progressbar

提问by Mridang Agarwalla

I've tried to show an indeterminate activity circle like this one:

我试图展示一个像这样的不确定活动圈:

enter image description here

在此处输入图片说明

Here's the layout code:

这是布局代码:

<ProgressBar
    android:id="@+id/progress"
    style="@style/GenericProgressIndicator"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_gravity="center_vertical|center_horizontal"
    android:visibility="gone" />

Here's the styling code:

这是样式代码:

<style name="GenericProgressIndicator" parent="@android:style/Widget.ProgressBar.Large">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:indeterminate">true</item>
</style>

My circle doesn't look anything like the Holo themed circle that you see in the Gmail App or the Play app. What am I doing wrong? How can I get the nice Holo animated activity circle?

我的圈子看起来不像您在 Gmail 应用或 Play 应用中看到的 Holo 主题圈。我究竟做错了什么?如何获得漂亮的 Holo 动画活动圈?

回答by Mridang Agarwalla

This really wasn't documented anywhere and I found it through some random article. Adding this styling attribute does the trick:

这真的没有在任何地方记录,我是通过一些随机文章找到的。添加此样式属性可以解决问题:

style="?android:attr/progressBarStyleLarge"

The only reference to this on the developer documentation is here.

开发人员文档中对此的唯一参考是here

回答by vault

Your first layout was right but you chose the wrong style. The right one is:

您的第一个布局是正确的,但您选择了错误的样式。正确的是:

style="@android:style/Widget.Holo.Light.ProgressBar.Large"

回答by CNorris

What version of Android are you using? If you're not using a version with Holo, you won't be able to display things using the Holo style. A solution to that is to use a library like ActionBarSherlock, which backports the Holo theme to previous Android versions.

你用的是什么版本的安卓?如果您没有使用 Holo 的版本,您将无法使用 Holo 样式显示内容。一个解决方案是使用像 ActionBarSherlock 这样的库,它将 Holo 主题向后移植到以前的 Android 版本。