【发布时间】:2013-11-27 22:52:07
【问题描述】:
我正在尝试按照 android 教程 (here) 更改 由 Eclipse 向导制作的新 Android 应用程序 的 ActionBar 颜色,但我遇到了几个问题。
我将 minSdkVersion 设置为 10(应该是 android 2.1 左右)。
当我将此代码粘贴到themes.xml 中时(如教程所述):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@style/AppTheme">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@style/AppTheme">
<item name="android:background">#FFFFFF</item>
<!-- Support library compatibility -->
<item name="background">#FFFFFF</item>
</style>
</resources>
Eclipse 给我这些错误:
- 第 5 行:android:actionBarStyle 需要 API 级别 11(当前最小值为 10)
- 第 8 行:错误:错误:未找到与给定匹配的资源 名称:attr 'actionBarStyle'。
- 第 16 行:错误:错误:未找到资源 匹配给定名称:attr 'background'。
我修改了一些小东西(基本主题和颜色),但是教程中提供了干净的代码。
我的 Styles.xml 在这里:
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
有什么问题?
【问题讨论】:
-
你在你的android项目中引用了app compact吗?
-
你能贴出你如何解决的代码吗?
标签: android colors android-actionbar