我正在学习“设置操作栏样式”教程:http://developer.android.com/training/basics/actionbar/styling.html
我在@drawable/actionbar_background 上收到“无法解析符号”和错误
据我所知,我在可绘制对象下没有“actionbar_background”。我不明白的是“actionbar_background”是什么。
这是 res/value/themes.xml 示例中的部分代码
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/actionbar_background</item>
</style>
</resources>
最佳答案
I don't have an "actionbar_background" under drawable, that I understand. What I don't understand is what "actionbar_background" is.
它是一个资源文件,一个xml
或一个png
,存储在res/drawable-*
文件夹中。
尝试创建一个名为 actionbar_background.xml
的 xml 文件,并将其存储在 res/drawable
中,内容如下:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#FFFF00"/>
</shape>
关于Android - 将背景应用到操作栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30357242/