【发布时间】:2016-03-30 10:34:32
【问题描述】:
我正在尝试设置 ActionBar 的样式。我在 values 文件夹中创建了我的自定义样式。未发现错误。我运行了我的应用程序,它运行良好。但是,我的自定义样式不起作用,我不知道为什么。我做了所有我想要的改变。
我已经在清单中声明了活动主题
android:theme="@style/Theme.AndroidDevelopers"
当我运行它时,应用程序出现一个丑陋的操作栏(背景灰色,弹出菜单灰色和文本黑色......默认的蓝色方案) - 它与我的自定义样式无关:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.AndroidDevelopers" parent="android:style/Theme.Holo.Light">
<item name="android:selectableItemBackground">@drawable/ab_item_background</item>
<item name="android:popupMenuStyle">@style/MyPopupMenu</item>
<item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
<item name="android:listChoiceIndicatorMultiple">@color/amarelo</item>
<item name="android:listChoiceIndicatorSingle">@color/vermelho</item>
</style>
<!-- style the list navigation -->
<style name="MyDropDownNav" parent="android:style/Widget.Holo.Light.Spinner">
<item name="android:background">@color/vermelho</item>
<item name="android:popupBackground">@color/orange</item>
<item name="android:dropDownSelector">@drawable/seletor2</item>
</style>
<!-- style for the tabs -->
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">@color/verdeclaro</item>
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>
<!-- style the overflow menu -->
<style name="MyPopupMenu" parent="android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">@color/branco</item>
</style>
<!-- style the items within the overflow menu -->
<style name="MyDropDownListView" parent="android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">@drawable/seletor2</item>
</style>
<style name="MyActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@drawable/actionbarbackground</item>
</style>
</resources>`
【问题讨论】:
-
看这个答案,你必须提到单独的
item names 以获得支持库stackoverflow.com/a/27847656/4387543
标签: android android-actionbar android-spinner android-styles