我用 ActionBarSherlock 做了一个动作栏。我想设置操作栏的样式,所以当我按下菜单项(从溢出中弹出的下拉项)时,菜单项背景应该改变颜色。(现在它变为默认的全息蓝色,我希望它是另一种颜色)。
经过长时间的谷歌搜索和测试,a 想出了这个:
themes.xml
:
<style name="AppTheme" parent="Holo.Theme">
<item name="android:popupMenuStyle">@style/PopupMenuStyle</item>
<item name="popupMenuStyle">@style/PopupMenuStyle</item>
</style>
<style name="PopupMenuStyle" parent="@style/Widget.Sherlock.PopupMenu">
<item name="android:dropDownSelector">@drawable/menu_selector</item>
</style>
menu_selector.xml
: (喜欢abs__list_selector_holo_dark.xml
)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:drawable="@android:color/transparent" />
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/abs__list_selector_disabled_holo_dark" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/abs__list_selector_disabled_holo_dark" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@color/AppRed" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@color/AppRed" />
<item android:state_focused="true" android:drawable="@drawable/abs__list_focused_holo" />
<item android:drawable="@color/AppRed" />
</selector>
不幸的是,背景仍然变为蓝色而不是红色。我在这里想念什么?