首页 文章

某些ProgressBar样式未在Nexus 5 Android 5.0.1上显示

提问于
浏览
25

我有以下布局:

<?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 罚款 . 在开发人员选项中启用'draw layout borders'选项,它显示 ProgressBar 包含在布局中,它根本不显示 .

这看起来很奇怪,对于这里可能会发生什么的任何想法?

enter image description here

3 回答

  • 5

    我遇到了同样的问题,但是因为开发者手机的动画缩放为0(全部为3) .

    启用设备上的所有动画,也许您将能够看到进度条,因此对于将启用动画的普通人,进度条将显示正常 .

  • 28

    就我而言,看起来问题是构建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" />
    
  • 1

    通过将样式设置为以下代码,您应该能够调试此问题

    style="?android:attr/progressBarStyleLarge"
    

相关问题