0

在覆盖 ActionBarSherlock 样式时遇到一些麻烦,希望有人可以提供帮助。我创建了一个像这样的drawable:

(在 res/drawable/actionbar_background.xml 中)

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/bg"
    android:tileMode="repeat" />

然后在我的应用程序的样式文件中(在 res/values/style.xml 中)

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="ActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/actionbar_background</item>
</style>
<style name="my_theme" parent="@style/Theme.Sherlock.Light">
        <item name="android:actionBarStyle">@style/ActionBar</item>
    </style>
</resources>

结果是选择了 Theme.Sherlock.Light 样式(或者如果我交换它,则选择 Theme.Sherlock),但我没有对操作栏背景本身的样式进行任何更改。

谢谢

4

2 回答 2

12

这应该为您提供带有自定义操作栏背景的 Theme.Sherlock.Light 样式:

<style name="ActionBar" parent="Theme.Sherlock.Light">
    <item name="abBackground">@drawable/actionbar_background</item>
</style>

将它放在您的 res/values/style.xml 文件中,并在清单中将您的样式声明为 @style/ActionBar。

更多信息 - http://actionbarsherlock.com/theming.html

于 2012-02-06T15:16:25.090 回答
6

对于 4.0+ 版本,您可以简单地使用“背景”项目名称。

<style name="ActionBar" parent="Theme.Sherlock.Light">
    <item name="background">@drawable/actionbar_background</item>
</style>
于 2012-03-31T01:32:29.103 回答