Android - 将背景应用到操作栏
Android - Apply background to the action bar
我正在学习 "Styling the Action Bar" 教程:http://developer.android.com/training/basics/actionbar/styling.html
然后我在@drawable/actionbar_background
上收到 "Cannot resolve symbol" 和错误
据我所知,我没有 "actionbar_background" under drawable。我不明白的是 "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>
我正在学习 "Styling the Action Bar" 教程:http://developer.android.com/training/basics/actionbar/styling.html
然后我在@drawable/actionbar_background
上收到 "Cannot resolve symbol" 和错误据我所知,我没有 "actionbar_background" under drawable。我不明白的是 "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>