设置溢出菜单文本颜色

时间:2013-06-03 20:13:47

标签: android

在我的主题中,我包含了这个:

<item name="android:popupMenuStyle">@style/ListPopupWindow</item>
styles.xml中的

<style name="ListPopupWindow" parent="@android:style/Widget.Holo.ListPopupWindow">
    <item name="android:textColor">@color/bright_foreground_holo_dark</item>    
</style>

其中bright_foreground_holo_dark为浅灰色(#fff3f3f3)。然而,文字显示为黑色。背景是深灰色,因为它应该是黑暗的全息主题。

这些定义位于android styles.xml source

<style name="Widget.Holo.ListPopupWindow" parent="Widget.ListPopupWindow">
    <item name="android:dropDownSelector">@android:drawable/list_selector_holo_dark</item>
    <item name="android:popupBackground">@android:drawable/menu_dropdown_panel_holo_dark</item>
    <item name="android:dropDownVerticalOffset">0dip</item>
    <item name="android:dropDownHorizontalOffset">0dip</item>
    <item name="android:dropDownWidth">wrap_content</item>
</style>

<style name="Widget.ListPopupWindow">
    <item name="android:dropDownSelector">@android:drawable/list_selector_background</item>
    <item name="android:popupBackground">@android:drawable/spinner_dropdown_background</item>
    <item name="android:dropDownVerticalOffset">-10dip</item>
    <item name="android:dropDownHorizontalOffset">0dip</item>
    <item name="android:dropDownWidth">wrap_content</item>        
</style>

<style name="Widget">
    <item name="android:textAppearance">?textAppearance</item>
</style>

<style name="TextAppearance">
    <item name="android:textColor">?textColorPrimary</item>
    <item name="android:textColorHighlight">?textColorHighlight</item>
    <item name="android:textColorHint">?textColorHint</item>
    <item name="android:textColorLink">?textColorLink</item>
    <item name="android:textSize">16sp</item>
    <item name="android:textStyle">normal</item>
</style>

1 个答案:

答案 0 :(得分:12)

以防有人寻求帮助,

要更改溢出菜单项的字体颜色,您的主题应包括

<item name="android:textAppearanceLargePopupMenu">@style/PopupMenuTextAppearance</item>

并在style.xml

<style name="PopupMenuTextAppearance" parent="android:TextAppearance.Large">
    <item name="android:textColor">@color/bright_foreground_holo_dark</item>
</style>

根据需要选择任何父TextAppearance.Medium / TextAppearance.Small