我使用Android Asset Studio来生成动作栏样式,但是我想做一些改变,我在Studio中无法做到这一点,所以我编辑了生成的主题,但很多东西都被忽略了,我只是可以弄清楚事情是如何运作的。 有例子: `
<style name="Theme.Myactionbar" parent="@style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">@drawable/selectable_background_myactionbar</item>
<item name="popupMenuStyle">@style/PopupMenu.Myactionbar</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Myactionbar</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle.Myactionbar</item>
<item name="actionDropDownStyle">@style/DropDownNav.Myactionbar</item>
<item name="actionBarStyle">@style/ActionBar.Solid.Myactionbar</item>
<item name="actionModeBackground">@drawable/cab_background_top_myactionbar</item>
<item name="actionModeSplitBackground">@drawable/cab_background_bottom_myactionbar</item>
<item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Myactionbar</item>
</style>
<style name="ActionBar.Solid.Myactionbar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">@drawable/ab_solid_myactionbar</item> //THIS IS GREEN
<item name="backgroundStacked">@drawable/ab_solid_myactionbar</item>//THIS IS GREEN
<item name="backgroundSplit">@drawable/ab_bottom_solid_myactionbar</item>//THIS IS GREEN
<item name="progressBarStyle">@style/ProgressBar.Myactionbar</item>
</style>
<style name="ActionBar.Transparent.Myactionbar" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="background">@drawable/ab_transparent_myactionbar</item>
<item name="progressBarStyle">@style/ProgressBar.Myactionbar</item>
</style>
<style name="PopupMenu.Myactionbar" parent="@style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_example </item>
</style>
<style name="DropDownListView.Myactionbar" parent="@style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_myactionbar</item>
</style>
<style name="ActionBarTabStyle.Myactionbar" parent="@style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_myactionbar</item>
</style>
<style name="DropDownNav.Myactionbar" parent="@style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">@drawable/spinner_background_ab_myactionbar</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_myactionbar</item>
<item name="android:dropDownSelector">@drawable/selectable_background_myactionbar</item>
</style>
<style name="ProgressBar.Myactionbar" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_myactionbar</item>
</style>
<style name="ActionButton.CloseMode.Myactionbar" parent="@style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_myactionbar</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Myactionbar.Widget" parent="@style/Theme.AppCompat">
<item name="popupMenuStyle">@style/PopupMenu.Myactionbar</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Myactionbar</item>
</style>
一切都像生成器一样,但后来我尝试了最简单的改变,即颜色,所以我编辑了样式名称= ActionBar.Solid.Myactionbar并将其他生成的样式放入其他可绘制的内容中。 它看起来像这样:
<style name="Theme.Myactionbar" parent="@style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">@drawable/selectable_background_myactionbar</item>
<item name="popupMenuStyle">@style/PopupMenu.Myactionbar</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Myactionbar</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle.Myactionbar</item>
<item name="actionDropDownStyle">@style/DropDownNav.Myactionbar</item>
<item name="actionBarStyle">@style/ActionBar.Solid.Myactionbar</item>
<item name="actionModeBackground">@drawable/cab_background_top_myactionbar</item>
<item name="actionModeSplitBackground">@drawable/cab_background_bottom_myactionbar</item>
<item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Myactionbar</item>
</style>
<style name="ActionBar.Solid.Myactionbar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">@drawable/ab_solid_example</item>
<item name="backgroundStacked">@drawable/ab_stacked_solid_example</item>
<item name="backgroundSplit">@drawable/ab_bottom_solid_myactionbar</item>
<item name="progressBarStyle">@style/ProgressBar.Myactionbar</item>
</style>
但没有任何事情发生,并且改变了drawables应该是灰色的。如果以前有人这样做过,我在徘徊,为什么这不起作用?谢谢
答案 0 :(得分:1)
好的我想通了,api 14级及以上的样式有值-v14文件夹,所以你也要改变这些值。