我正在设置操作栏的背景颜色,我无法做到。
我在values-v11文件夹中的styles.xml如下
<resources>
<!--
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:style/Theme.Holo">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- API 11 theme customizations can go here. -->
</style>
<style name="MyActionBar">
<item name="android:background">#99DD00</item>
</style>
</resources>
答案 0 :(得分:1)
确定的问题是styles.xml(v-14)包含一个具有相同名称的空标记,并且从那里拾取主题
<style name="AppBaseTheme" >
</style>
答案 1 :(得分:0)
我在我的应用程序中使用以下内容并且它完美地运行:
<resources>
<!-- Base application theme. -->
<style name="CustomActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:height">65dp</item>
<item name="android:background">@android:color/black</item>
</style>
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/CustomActionBar</item> </style>
</resources>
答案 2 :(得分:0)
Android 3.0 仅限
//res/values/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>
Android 2.1 及更高版本
//res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/actionbar_background</item>
<!-- Support library compatibility -->
<item name="background">@drawable/actionbar_background</item>
</style>
</resources>
然后将您的主题应用于整个应用或个人活动:
<application android:theme="@style/CustomActionBarTheme" ... />