Certain ProgressBar styles not shown on Nexus 5 Android 5.0.1

混江龙づ霸主 提交于 2019-11-29 01:06:55

I was having the same issue but was because the developer phone have animations scales to 0 (all 3).

Enable all the animations on the device and maybe you will be able to see the progress bar, so for normal people that will have animations enabled the progress bar will appear fine.

In my case, it looks as if the issue is with build LRX22G:

Nexus 7 using Build LRX22G (android-5.0.2_r1) - progress bar not shown

Nexus 5 using Build LRX22C (android-5.0.1_r1) - progress bar shown

See https://source.android.com/source/build-numbers.html

It's probably also related with https://code.google.com/p/android/issues/detail?id=77865

Not being able to wait for a fix, what I've decided to do is to force the Holo progress bar to be used in my Material theme. This is how it was achieved - it may be of some use to you in the meantime:

<style name="AppBaseTheme" parent="@android:style/Theme.Material.Light.DarkActionBar">

    <!-- Build LRX22G (5.0.2 Nexus 7) fails to display progress bar so we'll use Holo instead of Material -->
    <!-- http://stackoverflow.com/questions/27567235/certain-progressbar-styles-not-shown-on-nexus-5-android-5-0-1 -->
    <item name="android:progressBarStyleSmall">@style/MaterialProgressBarFix.Small</item>
    <item name="android:progressBarStyle">@style/MaterialProgressBarFix</item>
    <item name="android:progressBarStyleLarge">@style/MaterialProgressBarFix.Large</item>
</style>

<style name="MaterialProgressBarFix.Small" parent="@android:style/Widget.Holo.ProgressBar.Small" />
<style name="MaterialProgressBarFix"       parent="@android:style/Widget.Holo.ProgressBar" />
<style name="MaterialProgressBarFix.Large" parent="@android:style/Widget.Holo.ProgressBar.Large" />

By setting the style to the following instead you should be able to debug this issue

style="?android:attr/progressBarStyleLarge"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!