大家好,我是 Android 开发的新手,我正在努力更改 ActionBar 的背景。在我的 themes.xml
文件中添加以下内容时 res->values
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/actionbar_background</item>
</style>
我收到此错误消息:
error: Error: No resource found that matches the given name (at 'android:background' with value '@drawable/
actionbar_background').
我不确定为什么我会收到此消息并且需要帮助。
大卫
最佳答案
只是猜测,但我敢打赌你没有任何名为 actionbar_background.png
仔细检查您的 png 资源中是否存在拼写错误。它应该在任何 drawable
文件夹中。或者你可以设置一种颜色。-
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#FF0000</item>
</style>
请注意,硬编码值是一种不好的做法。如果您最终选择背景颜色,则应考虑在单独的资源文件(即 colors.xml)中为该颜色创建资源项
<color name="red">#FF0000</color>
并在您的项目样式中使用 @color/red
引用它
关于android - 更改 ActionBar 背景的问题 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19084400/