ActionBar list navigation: different text color in header and pop up menu

actionbarsherlock, android, android-actionbar

Solution

The problem is that you are using the same resource `android.R.layout.simple_dropdown_item_1line` for the spinner item and the spinner dropdown item.

Use `R.layout.sherlock_spinner_item` and `R.layout.sherlock_spinner_dropdown_item` instead.

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
         R.layout.sherlock_spinner_item, new String[] { "Item 1", "Item 2" });
adapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);

This way, the styles like `Widget.Sherlock.TextView.SpinnerItem` will work.

Problem

I have a navigation list in my action bar that has a dark background. The pop menu however, has a white background. So what I want to achieve is, that the item text color inside of the action bar is white whereas the items text color in the menu pop up are black. This are two examples what I got so far: This is how it should look like: Does anyone know a solution? This is my code for the list navigation: ``` ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, new String[] { "Item 1", "Item 2" }); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setListNavigationCallbacks(adapter, new ActionBar.OnNavigationListener() { @Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { return true; } }); getSupportActionBar().setSelectedNavigationItem(0) ``` These is a collection of styles that I worked with. ``` <style name="CustomTheme" parent="@style/Theme.customized"> <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item> <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item> <item name="actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <item name="android:actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <!-- didn't work: http://stackoverflow.com/questions/12395381/android-actionbar-navigation-spinner-text-color <item name="android:spinnerDropDownItemStyle">@style/custom.Widget.DropDownItem.Spinner</item> <item name="spinnerDropDownItemStyle">@style/custom.Widget.DropDownItem.Spinner</item> --> <!-- didn't work: http://stackoverflow.com/questions/11479186/styling-actionbar-dropdown-menu <item name="android:actionBarWidgetTheme">@style/custom.actionBarWidgetTheme</item> <item name="actionBarWidgetTheme">@style/custom.actionBarWidgetTheme</item> --> <!-- didn't work: http://android-developers.blogspot.de/2011/04/customizing-action-bar.html <item name="android:dropDownListViewStyle">@style/CustomDropDownListView</item> <item name="dropDownListViewStyle">@style/CustomDropDownListView</item> --> .... </style> <style name="custom.actionBarWidgetTheme" parent="@style/Theme.Sherlock.Light.DarkActionBar"> <item name="android:spinnerDropDownItemStyle">@style/custom.Widget.DropDownItem.Spinner</item> </style> <style name="custom.Widget.DropDownItem.Spinner" parent="@style/Widget.Sherlock.DropDownItem.Spinner"> <item name="android:textAppearance">@style/custom.TextAppearance.Widget.DropDownItem</item> </style> <style name="custom.TextAppearance.Widget.DropDownItem" parent="@style/TextAppearance.Sherlock.Widget.DropDownItem"> <item name="android:textColor">#00A000</item> </style> <style name="CustomDropDownListView" parent="android:style/Widget.Holo.ListView.DropDown"> <item name="android:textColor">#00A000</item> <item name="android:textSize">8dip</item> </style> <style name="CustomSherlockDropDownNav" parent="@style/Widget.Sherlock.Light.Spinner.DropDown.ActionBar"> <item name="android:popupBackground">@drawable/menu_dropdown_panel_customtab</item> <item name="android:background">@drawable/spinner_background_ab_customtab</item> </style> ``` However nothing didn't work.

Original source

Related problems