【发布时间】:2018-11-13 16:01:05
【问题描述】:
我正在尝试将主题应用于我的应用程序中的所有进度条。在清单中,我应用了一个名为 AppTheme 的自定义主题。在这种风格中,我添加了一个额外的progressBarStyle 项目,如下所示:
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
...
<item name="android:progressBarStyle">@style/my_progress_bar</item>
</style>
我这样定义自定义栏进度样式:
<style name="my_progress_bar" parent="Base.Widget.AppCompat.ProgressBar">
<item name="android:indeterminateTint">@color/app_black</item>
<item name="android:indeterminateTintMode">src_in</item>
</style>
如果我将此样式应用于单个 ProgressBar 视图,它会起作用,但我想通过 AppTheme 在我的清单中应用它,这样我就不必为应用程序中的每个进度条指定相同的 tint 和 tintMode。我正在使用运行 API 25 的设备。
我做错了什么?感谢您提供任何见解。
编辑:经过进一步调查,由于某种原因,将样式添加到 AppTheme 不会传播到清单。如果我完全用我的进度条样式替换 AppTheme,它就可以工作。但我仍然需要AppTheme 中定义的样式。
这有效:
<application ...
android:theme="@style/my_progress_bar">
但这不是:
<application ...
android:theme="@style/AppTheme">
有趣的是,如果我删除 AppTheme 中除了我定义的进度条样式之外的所有内容,它就不起作用。 android中是否存在嵌套样式的错误?当我将它传递给这个 AppTheme 时,我的清单没有看到定义的 progressBarStyle:
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:progressBarStyle">@style/my_progress_bar</item>
</style>
【问题讨论】:
标签: android android-manifest android-theme android-progressbar