我有以下布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="@android:style/Widget.Material.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
我有一个运行Android 5.0.1
的Nexus 5没有显示ProgressBar
,显然是因为样式。当我将样式设置为
style="@android:style/Widget.ProgressBar.Large"
或
style="@android:style/Widget.Holo.ProgressBar.Large"
显示。我有一个相同的Nexus 5也运行Android 5.0.1
,显示所有ProgressBar
的罚款。
在开发人员选项中启用“绘制布局边框”选项后,它会显示布局中包含ProgressBar
,但它不会显示。
这看起来很奇怪,对这里可能会发生什么的任何想法?
答案 0 :(得分:28)
我遇到了同样的问题,但是因为开发者手机的动画缩放为0(全部为3)。
启用设备上的所有动画,也许您将能够看到进度条,因此对于已启用动画的普通人,进度条将显示正常。
答案 1 :(得分:5)
就我而言,看起来问题是构建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
请参阅https://source.android.com/source/build-numbers.html
它可能也与https://code.google.com/p/android/issues/detail?id=77865
有关无法等待修复,我决定做的是强制在我的材质主题中使用Holo进度条。这就是它的实现方式 - 在此期间它可能对你有用:
<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" />
答案 2 :(得分:1)
通过将样式设置为以下代码,您应该可以调试此问题
style="?android:attr/progressBarStyleLarge"