ActionBarSherlock开源项目地址:https://github.com/JakeWharton/ActionBarSherlock
为了实现ActionBar的自定义,我们可以研究下abs库的两个style配置文件:
abs__themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style parent="Android:Theme.NoTitleBar">
<item>@null</item>
</style>
<style parent="android:Theme.Light.NoTitleBar">
<item>@null</item>
</style>
<style parent="Theme.Sherlock.Light">
</style>
<style parent="android:Theme.Dialog">
</style>
<style parent="Sherlock.__Theme">
<!-- Action bar styles (from Theme.Holo) -->
<item>@style/Widget.Sherlock.Spinner.DropDown.ActionBar</item>
<item>@style/Widget.Sherlock.ActionButton</item>
<item>@style/Widget.Sherlock.ActionButton.Overflow</item>
<item>@drawable/abs__cab_background_top_holo_dark</item>
<item>@drawable/abs__cab_background_bottom_holo_dark</item>
<item>@drawable/abs__ic_cab_done_holo_dark</item>
<item>@style/Widget.Sherlock.ActionBar.TabView</item>
<item>@style/Widget.Sherlock.ActionBar.TabBar</item>
<item>@style/Widget.Sherlock.ActionBar.TabText</item>
<item>@style/Widget.Sherlock.ActionMode</item>
<item>@style/Widget.Sherlock.ActionButton.CloseMode</item>
<item>@style/Widget.Sherlock.ActionBar</item>
<item>@dimen/abs__action_bar_default_height</item>
<!-- Internal --><item>@style/Widget.Sherlock.PopupWindow.ActionMode</item>
<item>@null</item>
<!-- Action bar styles (defaults from Theme) -->
<item>?attr/actionBarStyle</item>
<item>@style/TextAppearance.Sherlock.Widget.ActionBar.Menu</item>
<item>?attr/textColorPrimary</item>
<item>?attr/dividerVertical</item>
<item>?attr/selectableItemBackground</item>
<item>@style/Widget.Sherlock.Button.Small</item>
<item>@drawable/abs__item_background_holo_dark</item>
<item>@drawable/abs__activated_background_holo_dark</item>
<item>@drawable/abs__ic_menu_share_holo_dark</item>
<item>@style/Widget.Sherlock.ActivityChooserView</item>
<item>@drawable/abs__ic_ab_back_holo_dark</item>
<item>@drawable/abs__list_divider_holo_dark</item>
<item>@style/Widget.Sherlock.DropDownItem.Spinner</item>
<item>@style/Widget.Sherlock.TextView.SpinnerItem</item>
<item>@color/abs__primary_text_holo_dark</item>
<item>@color/abs__primary_text_disable_only_holo_dark</item>
<item>@color/abs__primary_text_holo_light</item>
<!-- Internal --><item>48dip</item>
<item>@style/Widget.Sherlock.ListView.DropDown</item>
<item>@style/TextAppearance.Sherlock.Small</item>
<item>@style/TextAppearance.Sherlock.Widget.PopupMenu.Large</item>
<item>@style/TextAppearance.Sherlock.Widget.PopupMenu.Small</item>
<item>@style/Widget.Sherlock.PopupMenu</item>
<!-- Internal --><item>@style/Widget.Sherlock.ListPopupWindow</item>
<item>@drawable/abs__search_dropdown_dark</item>
<item>@drawable/abs__textfield_searchview_holo_dark</item>
<item>@drawable/abs__textfield_searchview_right_holo_dark</item>
<item>@drawable/abs__ic_clear</item>
<item>@drawable/abs__ic_search</item>
<item>@drawable/abs__ic_go</item>
<item>@drawable/abs__ic_voice_search</item>
<item>@style/Widget.Sherlock.SearchAutoCompleteTextView</item>
<item>@style/TextAppearance.Sherlock.Widget.DropDownHint</item>
<item>true</item>
<item>false</item>
<item>@null</item>
</style>
<style parent="Sherlock.__Theme.Light">
<!-- Action bar styles (from Theme.Holo) -->
<item>@style/Widget.Sherlock.Light.Spinner.DropDown.ActionBar</item>
<item>@style/Widget.Sherlock.Light.ActionButton</item>
<item>@style/Widget.Sherlock.Light.ActionButton.Overflow</item>
<item>@drawable/abs__cab_background_top_holo_light</item>
<item>@drawable/abs__cab_background_bottom_holo_light</item>
<item>@drawable/abs__ic_cab_done_holo_light</item>
<item>@style/Widget.Sherlock.Light.ActionBar.TabView</item>
<item>@style/Widget.Sherlock.Light.ActionBar.TabBar</item>
<item>@style/Widget.Sherlock.Light.ActionBar.TabText</item>
<item>@style/Widget.Sherlock.Light.ActionMode</item>
<item>@style/Widget.Sherlock.Light.ActionButton.CloseMode</item>
<item>@style/Widget.Sherlock.Light.ActionBar.Solid</item>
<item>@dimen/abs__action_bar_default_height</item>
<!-- Internal --><item>@style/Widget.Sherlock.Light.PopupWindow.ActionMode</item>
<item>@null</item>
<!-- Action bar styles (defaults from Theme) -->
<item>?attr/actionBarStyle</item>
<item>@style/TextAppearance.Sherlock.Widget.ActionBar.Menu</item>
<item>?attr/textColorPrimary</item>
<item>?attr/dividerVertical</item>
<item>?attr/selectableItemBackground</item>
<item>@style/Widget.Sherlock.Light.Button.Small</item>
<item>@drawable/abs__item_background_holo_light</item>
<item>@drawable/abs__activated_background_holo_light</item>
<item>@drawable/abs__ic_menu_share_holo_light</item>
<item>@style/Widget.Sherlock.Light.ActivityChooserView</item>
<item>@drawable/abs__ic_ab_back_holo_light</item>
<item>@drawable/abs__list_divider_holo_light</item>
<item>@style/Widget.Sherlock.Light.DropDownItem.Spinner</item>
<item>@style/Widget.Sherlock.TextView.SpinnerItem</item>
<item>@color/abs__primary_text_holo_light</item>
<item>@color/abs__primary_text_disable_only_holo_light</item>
<item>@color/abs__primary_text_holo_dark</item>
<!-- Internal --><item>48dip</item>
<item>@style/Widget.Sherlock.Light.ListView.DropDown</item>
<item>@style/TextAppearance.Sherlock.Light.Small</item>
<item>@style/TextAppearance.Sherlock.Light.Widget.PopupMenu.Large</item>
<item>@style/TextAppearance.Sherlock.Light.Widget.PopupMenu.Small</item>
<item>@style/Widget.Sherlock.Light.PopupMenu</item>
<!-- Internal --><item>@style/Widget.Sherlock.Light.ListPopupWindow</item>
<item>@drawable/abs__search_dropdown_light</item>
<item>@drawable/abs__textfield_searchview_holo_light</item>
<item>@drawable/abs__textfield_searchview_right_holo_light</item>
<item>@drawable/abs__ic_clear_holo_light</item>
<item>@drawable/abs__ic_search_api_holo_light</item>
<item>@drawable/abs__ic_go_search_api_holo_light</item>
<item>@drawable/abs__ic_voice_search_api_holo_light</item>
<item>@style/Widget.Sherlock.Light.SearchAutoCompleteTextView</item>
<item>@style/TextAppearance.Sherlock.Widget.DropDownHint</item>
<item>true</item>
<item>false</item>
<item>@null</item>
</style>
<style parent="Sherlock.__Theme.DarkActionBar">
<item>@drawable/abs__ab_solid_shadow_holo</item>
<item>@style/Widget.Sherlock.Light.ActionBar.Solid.Inverse</item>
<item>@style/Theme.Sherlock</item>
<item>@style/Widget.Sherlock.Spinner.DropDown.ActionBar</item>
<item>@style/Widget.Sherlock.ActionButton</item>
<item>@style/Widget.Sherlock.ActionButton.Overflow</item>
<item>@drawable/abs__cab_background_top_holo_dark</item>
<item>@drawable/abs__cab_background_bottom_holo_dark</item>
<item>@drawable/abs__ic_cab_done_holo_dark</item>
<item>@drawable/abs__ic_ab_back_holo_dark</item>
<item>@style/Widget.Sherlock.Light.ActionBar.TabView.Inverse</item>
<item>@style/Widget.Sherlock.Light.ActionBar.TabBar.Inverse</item>
<item>@style/Widget.Sherlock.Light.ActionBar.TabText.Inverse</item>
<item>@drawable/abs__list_divider_holo_dark</item>
<item>@drawable/abs__item_background_holo_dark</item>
<item>?attr/textColorPrimaryInverse</item>
<item>@style/Widget.Sherlock.Light.ActionMode.Inverse</item>
<item>@style/Widget.Sherlock.ActionButton.CloseMode</item>
<item>@style/Widget.Sherlock.PopupWindow.ActionMode</item>
<item>@drawable/abs__ic_menu_share_holo_dark</item>
</style>
<style>
<item>false</item>
<item>true</item>
</style>
<style>
<item>false</item>
<item>true</item>
</style>
<style parent="android:Theme">
<item>@null</item>
<item>@style/DialogWindowTitle.Sherlock</item>
<item>@drawable/abs__dialog_full_holo_dark</item>
<item>true</item>
<item>@null</item>
<item>@android:style/Animation.Dialog</item>
<item>stateUnspecified|adjustPan</item>
<item>false</item>
<item>true</item>
<item>true</item>
<item>true</item>
<item>0.6</item>
<item>@null</item>
<item>@color/abs__primary_text_holo_dark</item>
<item>@color/abs__primary_text_holo_light</item>
<item>@dimen/abs__dialog_min_width_major</item>
<item>@dimen/abs__dialog_min_width_minor</item>
<item>false</item>
<item>@null</item>
</style>
<style parent="android:Theme.Light">
<item>@null</item>
<item>@style/DialogWindowTitle.Sherlock.Light</item>
<item>@drawable/abs__dialog_full_holo_light</item>
<item>true</item>
<item>@null</item>
<item>@android:style/Animation.Dialog</item>
<item>stateUnspecified|adjustPan</item>
<item>false</item>
<item>true</item>
<item>true</item>
<item>true</item>
<item>0.6</item>
<item>@null</item>
<item>@color/abs__primary_text_holo_light</item>
<item>@color/abs__primary_text_holo_dark</item>
<item>@dimen/abs__dialog_min_width_major</item>
<item>@dimen/abs__dialog_min_width_minor</item>
<item>false</item>
<item>@null</item>
</style>
</resources>