@风格/ Theme.MyAppTheme.ActionBar
<item name="android:popupMenuStyle">@style/popupMenuStyle</item>
<item name="android:actionBarWidgetTheme">@style/Theme.MyTheme.Widget</item>
<item name="android:actionBarItemBackground">@null</item>
<item name="android:listPreferredItemHeightSmall">45dp</item>
<style name="popupMenuStyle" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
</style>
<style name="Theme.MyTheme.Widget" parent="@android:style/Theme.Holo">
<item name="android:textColor">#0675bc</item>
<item name="android:background">@android:color/white</item>
</style>
我有一个活动,它有动作栏溢出菜单和我的自定义弹出菜单我在上面的代码中使用Theme.MyTheme.Widget它工作正常但问题是我在另一个操作栏中使用搜索视图现在问题是,如果我使用上面的代码来更改溢出菜单背景,这些更改也适用于我不需要的搜索栏
答案 0 :(得分:0)
如果您的API是API级别14的最低级别,您可以使用此更改(为我工作)。
<style name="Theme.myapp" parent="@style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">@style/myapp_DropDownNav</item>
<item name="android:actionBarWidgetTheme">@style/myapp.actionBarWidgetTheme</item>
</style>
<style name="myapp.actionBarWidgetTheme" parent="@style/Theme.">
<item name="android:spinnerDropDownItemStyle">@style/myapp.Widget.DropDownItem.Spinner</item>
</style>
<style name="myapp_DropDownNav" parent="@style/Widget.Spinner.DropDown.ActionBar">
<item name="background">@drawable/spinner_background_ab_myapp</item>
<item name="android:background">@drawable/spinner_background_ab_myapp</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_myapp</item>
<item name="android:dropDownSelector">@drawable/selectable_background_myapp</item>
</style>
<style name="myapp.Widget.DropDownItem.Spinner" parent="Widget.DropDownItem.Spinner">
<item name="android:textAppearance">@style/myapp.TextAppearance.Widget.DropDownItem</item>
</style>
<style name="myapp.TextAppearance.Widget.DropDownItem" parent="TextAppearance.Widget.DropDownItem">
<item name="android:textColor">@color/black</item>
</style>
如果您使用的是ActionBarSherlock(最小API级别9),请尝试以下操作:
<style name="Theme.yourapp" parent="@style/Theme.Sherlock.Light">
<item name="popupMenuStyle">@style/PopupMenu.Style</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Style</item> </style>
<style name="PopupMenu.Style" parent="@style/Widget.Sherlock.Light.ListPopupWindow">
<item name="android:popupBackground">@drawable/your_background</item>
</style>
<style name="DropDownListView.Style" parent="@style/Widget.Sherlock.Light.ListView.DropDown">
<item name="android:listSelector">@drawable/your_background</item>
</style>
希望它可以帮到你!!