1

我可以设置从操作栏弹出的溢出菜单的样式,但我无法设置从硬件菜单按钮弹出的溢出菜单的样式。

我对菜单中项目的选择器的样式状态感兴趣。

欢迎任何想法?

4

1 回答 1

2

要自定义与硬件菜单按钮一起显示的弹出菜单,您需要在应用主题中包含此项目:

<style name="CustomTheme" parent="@style/Theme.AppCompat.Light">
    <item name="android:itemBackground">@drawable/ab_item_selector</item>  
</style> 

您可以@style/Theme.AppCompat.Light根据需要进行更改(如Holo或其他)。然后,命名的drawableab_item_selector可能是这样的:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- selected state -->
    <item 
        android:drawable="@drawable/item_selected" 
        android:state_selected="true"></item>
    <!-- pressed state -->
    <item 
        android:drawable="@drawable/item_pressed" 
        android:state_pressed="true"></item>
    <!-- normal state -->
    <item 
        android:drawable="@drawable/item_disabled"></item>
</selector> 

希望这可以帮助。


更新

对于分隔线,我不确定,但可能是:

<style name="CustomTheme" parent="@style/Theme.AppCompat.Light">
    <item name="android:dropDownListViewStyle">@style/CustomDropDown</item>
    <item name="dropDownListViewStyle">@style/CustomDropDown</item>
</style>

<style name="CustomDropDown" parent="@style/Widget.AppCompat.Light.ListView.DropDown">
    <item name="android:dividerHeight">1dip</item>
    <item name="android:divider">@drawable/dropdown_divider</item>
</style>  
于 2014-04-21T01:06:40.153 回答