【发布时间】:2014-03-31 07:25:05
【问题描述】:
我正在尝试更改我应用的ActionBar 的背景颜色。
我尝试了以下更改,
在 style.xml 文件中,我添加了“MyTheme”和“ActionBarBackground”,如下所示。
<resources>
<!--
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>
<style name="MyTheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">@style/ActionBarBackground</item>
</style>
<style name="ActionBarBackground" parent="AppBaseTheme">
<item name="android:background">#00008b</item>
</style>
</resources>
然后,
清单文件,我为特定的activity 添加如下,
<activity android:name="LoginActivity" android:theme="@style/ActionBarBackground">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
发生的情况是,整个活动视图的背景变为蓝色,而不是仅更改操作栏的颜色。
有人可以建议,我在这里做错了什么。
【问题讨论】:
-
试试我的答案。像我提到的那样,用 0x 和颜色十六进制值添加你的颜色代码。
-
你得到答案了吗?