要覆盖ActionBarSherlock
主题,您应该像这样进行:
values/abs__themes.xml
从ActionBarSherlock
库项目中打开。例如,您会看到:
<style name="Theme.Sherlock" parent="Sherlock.__Theme">
<!-- Action bar styles (from Theme.Holo) -->
<item name="actionDropDownStyle">@style/Widget.Sherlock.Spinner.DropDown.ActionBar</item>
<item name="actionButtonStyle">@style/Widget.Sherlock.ActionButton</item>
<item name="actionOverflowButtonStyle">@style/Widget.Sherlock.ActionButton.Overflow</item>
<item name="actionModeBackground">@drawable/abs__cab_background_top_holo_dark</item>
<item name="actionModeSplitBackground">@drawable/abs__cab_background_bottom_holo_dark</item>
<item name="actionModeCloseDrawable">@drawable/abs__ic_cab_done_holo_dark</item>
<item name="actionBarTabStyle">@style/Widget.Sherlock.ActionBar.TabView</item>
...
// Here is what you wanted
<item name="actionBarItemBackground">@drawable/abs__item_background_holo_dark</item>
...
当您找到要自定义的项目(actionBarItemBackground
在您的情况下)时,您可以在项目中创建自己themes.xml
的项目,然后添加:
<style name="Custom.Theme.Sherlock" parent="@style/Theme.Sherlock">
<item name="actionBarItemBackground">@drawable/my__item_background_holo_dark</item>
</style>
这会覆盖默认值Theme.Sherlock
,设置自定义actionBarItemBackground
。
现在,Theme.Sherlock
您应该使用setTheme(R.style.Custom_Theme_Sherlock)
. 您可能还想覆盖其他两个主题 (Theme.Sherlock.Light
和Theme.Sherlock.Light.DarkActionBar
)
还有一个提示,这里是用于ActionBarSherlock
默认操作项背景(在 holo_light 中)的可绘制选择器,它使用 9-patch png 可绘制对象:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/abs__list_selector_disabled_holo_light" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/abs__list_selector_disabled_holo_light" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/abs__list_selector_background_transition_holo_light" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/abs__list_selector_background_transition_holo_light" />
<item android:state_focused="true" android:drawable="@drawable/abs__list_focused_holo" />
<item android:drawable="@android:color/transparent" />
对于其他基本定制,您可以使用此工具,它会为您生成样式。