4

我试图弄清楚如何使用夏洛克操作栏将菜单项的文本颜色更改为不同的颜色。以下是我尝试过的主题

      <style name="MYTHEME" parent="Theme.Sherlock.Light.ForceOverflow">

         <item name="android:actionMenuTextColor">@color/menu_color</item>
         <item name="actionMenuTextColor">@color/menu_color</item>


        <item name="android:actionDropDownStyle">@style/MYTHEME.ActionBarStyle.DropDownStyle</item>
        <item name="actionDropDownStyle">@style/MYTHEME.ActionBarStyle.DropDownStyle</item>  

      </style>   

      <style name="MYTHEME.ActionBarStyle.DropDownStyle" parent="Widget.Sherlock.Spinner.DropDown.ActionBar">
        <item name="android:textColor">@color/menu_color</item>
      </style>

我能够使用上述更改菜单项的颜色,但无法通过“actionDropDownStyle”更改溢出菜单项的颜色...

我还查看了链接https://groups.google.com/forum/#!msg/actionbarsherlock/5lHOKNlXn_4/f9XicMXbFFAJ 但关于更改溢出菜单背景的问题只有一半的答案。

任何想法如何更改溢出菜单项的文本颜色?

4

2 回答 2

4

您必须创建自定义微调器样式,例如覆盖 ActionBarSherlock 库提供的样式:

<style name="SpinnerItemStyle" parent="Widget.Sherlock.TextView.SpinnerItem">
    <item name="android:textColor">@android:color/white</item>
    <item name="android:textSize">22sp</item>
    <item name="android:textStyle">bold</item>
    <item name="android:padding">4dp</item>
    <item name="android:gravity">left|center_vertical</item>        
</style>

然后,在您的主题中引用它,在 spinnerItemStyle 项目中:

<item name="spinnerItemStyle">@style/SpinnerItemStyle</item>

编辑:

注意:确保您的适配器将 com.actionbarsherlock.R.layout.sherlock_spinner_dropdown_item 作为下拉项,并将 com.actionbarsherlock.R.layout.sherlock_spinner_item 作为微调项:

ArrayAdapter<String> navigationAdapter = new ArrayAdapter<String>(context, com.actionbarsherlock.R.layout.sherlock_spinner_item, navigationItems);
navigationAdapter.setDropDownViewResource(com.actionbarsherlock.R.layout.sherlock_spinner_dropdown_item);
于 2012-07-23T15:21:07.980 回答
0

After lots of searching, one can modify text Color inside OverflowMenu of ActionBar for ActionBarSherlock. with following Theme Styles under parent style element only. Still haven't checked all the widget inside ActionBar changed or not. Please pardon for that if found out.

res\values\styles.xml

<style name="Theme.Zname" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarItemBackground">@drawable/selectable_background_zname</item>
    <item name="actionBarWidgetTheme">@style/Overflow.Text.Color</item>
</style>

<style name="Overflow.Text.Color" parent="Widget">
        <item name="android:textColor">@android:color/white</item>
</style>

res\values-v14\styles.xml

<style name="Theme.Zname" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarItemBackground">@drawable/selectable_background_zname</item>
    <item name="android:actionBarWidgetTheme">@style/Overflow.Text.Color</item>
</style>

<style name="Overflow.Text.Color" parent="Widget">
        <item name="android:textColor">@android:color/white</item>
</style>
于 2014-06-02T13:21:56.027 回答