android - 我的操作栏标题使用了错误的主题颜色

标签 android android-actionbar android-theme

我正在尝试修改我的应用程序的主题。我已经能够成功地为我的应用程序设置背景颜色,并为我的操作栏设置背景颜色。

不幸的是,操作栏中项目的背景颜色采用应用程序的背景颜色,而不是操作栏的背景颜色。

这是我在 styles.xml 中的代码

<!--
    Base application theme for API 11+. This theme completely replaces
    AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>


<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:background">#ff0000</item>
</style>


<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">#fefefe</item>
</style>

这是正在发生的事情的屏幕截图。

screenshot of weird bg colors

希望我在这里遗漏了一些愚蠢的东西......

谢谢!

最佳答案

我很确定您的主题背景已应用于一切。相反,您只希望 Activity 的背景是那种颜色。因此,与其在主题中设置背景色,不如为 Activity 设置。如果您有许多将使用此背景颜色的 Activity ,请为您的 Activity 创建一个样式并将其应用于每个 Activity 。

关于android - 我的操作栏标题使用了错误的主题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16039071/

相关文章:

android - 使用可观察时的实时数据异常

android - 搜索 View 光标颜色

Android ActionBar NullPointerException

Android Material 主题 alpha 颜色问题

android - 在 AppCompat 主题中覆盖默认 ListView 突出显示的颜色

android - AutoTransition 在 Motion 布局中不起作用

android - 滚动后自定义 ListView 始终未选中

android - 每次在 Android 上运行应用程序时,如何保存用户的选择?

android - Actionbar 列表导航宽度 - 换行内容

android - 如何更改 ProgressDialog 的颜色