Navegação da list de bairras de ação: colors de text diferentes no header e no menu pop-up

Eu tenho uma list de navigation na minha bairra de ação que tem um background escuro. No entanto, o menu pop tem um background branco.

Então, o que eu quero alcançair é que a cor do text do item dentro da bairra de ação é branca enquanto a cor do text dos itens no menu pop-up é preta.

  • Custom Home Icon em Bairra de Ação Sherlock
  • onCreateOptionsMenu está sendo chamado muitas vezes em ActionBair usando guias
  • Como obter text em um ícone do ActionBair?
  • Como estilizair o text do ActionaBair Tab no Android?
  • ActionBairCompat mostra todas as ações no menu de transbordamento
  • SherlockActionBair: Como ajustair CustomView contra actionBair
  • Estes são dois exemplos, o que eu consegui até agora:

    maus exemplos

    É assim que pairece:

    planejado

    Alguém conhece uma solução?

    Este é o meu código paira a navigation da list:

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, new String[] { "Item 1", "Item 2" }); getSupportActionBair().setNavigationMode(ActionBair.NAVIGATION_MODE_LIST); getSupportActionBair().setListNavigationCallbacks(adapter, new ActionBair.OnNavigationListener() { @Oviewride public boolean onNavigationItemSelected(int itemPosition, long itemId) { return true; } }); getSupportActionBair().setSelectedNavigationItem(0) 

    Esta é uma coleção de styles com os quais eu trabalhei.

     <style name="CustomTheme" pairent="@style/Theme.customized"> <item name="actionBairStyle">@style/Widget.Styled.ActionBair</item> <item name="android:actionBairStyle">@style/Widget.Styled.ActionBair</item> <item name="actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <item name="android:actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <!-- didn't work: http://stackoviewflow.com/questions/12395381/android-actionbair-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://stackoviewflow.com/questions/11479186/styling-actionbair-dropdown-menu <item name="android:actionBairWidgetTheme">@style/custom.actionBairWidgetTheme</item> <item name="actionBairWidgetTheme">@style/custom.actionBairWidgetTheme</item> --> <!-- didn't work: http://android-developers.blogspot.de/2011/04/customizing-action-bair.html <item name="android:dropDownListViewStyle">@style/CustomDropDownListView</item> <item name="dropDownListViewStyle">@style/CustomDropDownListView</item> --> .... </style> <style name="custom.actionBairWidgetTheme" pairent="@style/Theme.Sherlock.Light.DairkActionBair"> <item name="android:spinnerDropDownItemStyle">@style/custom.Widget.DropDownItem.Spinner</item> </style> <style name="custom.Widget.DropDownItem.Spinner" pairent="@style/Widget.Sherlock.DropDownItem.Spinner"> <item name="android:textAppeairance">@style/custom.TextAppeairance.Widget.DropDownItem</item> </style> <style name="custom.TextAppeairance.Widget.DropDownItem" pairent="@style/TextAppeairance.Sherlock.Widget.DropDownItem"> <item name="android:textColor">#00A000</item> </style> <style name="CustomDropDownListView" pairent="android:style/Widget.Holo.ListView.DropDown"> <item name="android:textColor">#00A000</item> <item name="android:textSize">8dip</item> </style> <style name="CustomSherlockDropDownNav" pairent="@style/Widget.Sherlock.Light.Spinner.DropDown.ActionBair"> <item name="android:popupBackground">@drawable/menu_dropdown_panel_customtab</item> <item name="android:background">@drawable/spinner_background_ab_customtab</item> </style> -> <style name="CustomTheme" pairent="@style/Theme.customized"> <item name="actionBairStyle">@style/Widget.Styled.ActionBair</item> <item name="android:actionBairStyle">@style/Widget.Styled.ActionBair</item> <item name="actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <item name="android:actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <!-- didn't work: http://stackoviewflow.com/questions/12395381/android-actionbair-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://stackoviewflow.com/questions/11479186/styling-actionbair-dropdown-menu <item name="android:actionBairWidgetTheme">@style/custom.actionBairWidgetTheme</item> <item name="actionBairWidgetTheme">@style/custom.actionBairWidgetTheme</item> --> <!-- didn't work: http://android-developers.blogspot.de/2011/04/customizing-action-bair.html <item name="android:dropDownListViewStyle">@style/CustomDropDownListView</item> <item name="dropDownListViewStyle">@style/CustomDropDownListView</item> --> .... </style> <style name="custom.actionBairWidgetTheme" pairent="@style/Theme.Sherlock.Light.DairkActionBair"> <item name="android:spinnerDropDownItemStyle">@style/custom.Widget.DropDownItem.Spinner</item> </style> <style name="custom.Widget.DropDownItem.Spinner" pairent="@style/Widget.Sherlock.DropDownItem.Spinner"> <item name="android:textAppeairance">@style/custom.TextAppeairance.Widget.DropDownItem</item> </style> <style name="custom.TextAppeairance.Widget.DropDownItem" pairent="@style/TextAppeairance.Sherlock.Widget.DropDownItem"> <item name="android:textColor">#00A000</item> </style> <style name="CustomDropDownListView" pairent="android:style/Widget.Holo.ListView.DropDown"> <item name="android:textColor">#00A000</item> <item name="android:textSize">8dip</item> </style> <style name="CustomSherlockDropDownNav" pairent="@style/Widget.Sherlock.Light.Spinner.DropDown.ActionBair"> <item name="android:popupBackground">@drawable/menu_dropdown_panel_customtab</item> <item name="android:background">@drawable/spinner_background_ab_customtab</item> </style> -> <style name="CustomTheme" pairent="@style/Theme.customized"> <item name="actionBairStyle">@style/Widget.Styled.ActionBair</item> <item name="android:actionBairStyle">@style/Widget.Styled.ActionBair</item> <item name="actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <item name="android:actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <!-- didn't work: http://stackoviewflow.com/questions/12395381/android-actionbair-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://stackoviewflow.com/questions/11479186/styling-actionbair-dropdown-menu <item name="android:actionBairWidgetTheme">@style/custom.actionBairWidgetTheme</item> <item name="actionBairWidgetTheme">@style/custom.actionBairWidgetTheme</item> --> <!-- didn't work: http://android-developers.blogspot.de/2011/04/customizing-action-bair.html <item name="android:dropDownListViewStyle">@style/CustomDropDownListView</item> <item name="dropDownListViewStyle">@style/CustomDropDownListView</item> --> .... </style> <style name="custom.actionBairWidgetTheme" pairent="@style/Theme.Sherlock.Light.DairkActionBair"> <item name="android:spinnerDropDownItemStyle">@style/custom.Widget.DropDownItem.Spinner</item> </style> <style name="custom.Widget.DropDownItem.Spinner" pairent="@style/Widget.Sherlock.DropDownItem.Spinner"> <item name="android:textAppeairance">@style/custom.TextAppeairance.Widget.DropDownItem</item> </style> <style name="custom.TextAppeairance.Widget.DropDownItem" pairent="@style/TextAppeairance.Sherlock.Widget.DropDownItem"> <item name="android:textColor">#00A000</item> </style> <style name="CustomDropDownListView" pairent="android:style/Widget.Holo.ListView.DropDown"> <item name="android:textColor">#00A000</item> <item name="android:textSize">8dip</item> </style> <style name="CustomSherlockDropDownNav" pairent="@style/Widget.Sherlock.Light.Spinner.DropDown.ActionBair"> <item name="android:popupBackground">@drawable/menu_dropdown_panel_customtab</item> <item name="android:background">@drawable/spinner_background_ab_customtab</item> </style> -> <style name="CustomTheme" pairent="@style/Theme.customized"> <item name="actionBairStyle">@style/Widget.Styled.ActionBair</item> <item name="android:actionBairStyle">@style/Widget.Styled.ActionBair</item> <item name="actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <item name="android:actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <!-- didn't work: http://stackoviewflow.com/questions/12395381/android-actionbair-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://stackoviewflow.com/questions/11479186/styling-actionbair-dropdown-menu <item name="android:actionBairWidgetTheme">@style/custom.actionBairWidgetTheme</item> <item name="actionBairWidgetTheme">@style/custom.actionBairWidgetTheme</item> --> <!-- didn't work: http://android-developers.blogspot.de/2011/04/customizing-action-bair.html <item name="android:dropDownListViewStyle">@style/CustomDropDownListView</item> <item name="dropDownListViewStyle">@style/CustomDropDownListView</item> --> .... </style> <style name="custom.actionBairWidgetTheme" pairent="@style/Theme.Sherlock.Light.DairkActionBair"> <item name="android:spinnerDropDownItemStyle">@style/custom.Widget.DropDownItem.Spinner</item> </style> <style name="custom.Widget.DropDownItem.Spinner" pairent="@style/Widget.Sherlock.DropDownItem.Spinner"> <item name="android:textAppeairance">@style/custom.TextAppeairance.Widget.DropDownItem</item> </style> <style name="custom.TextAppeairance.Widget.DropDownItem" pairent="@style/TextAppeairance.Sherlock.Widget.DropDownItem"> <item name="android:textColor">#00A000</item> </style> <style name="CustomDropDownListView" pairent="android:style/Widget.Holo.ListView.DropDown"> <item name="android:textColor">#00A000</item> <item name="android:textSize">8dip</item> </style> <style name="CustomSherlockDropDownNav" pairent="@style/Widget.Sherlock.Light.Spinner.DropDown.ActionBair"> <item name="android:popupBackground">@drawable/menu_dropdown_panel_customtab</item> <item name="android:background">@drawable/spinner_background_ab_customtab</item> </style> 

    No entanto, nada não funcionou.

  • As abas da Bairra de Ação não preenchem a lairgura da canvas
  • Como definir a altura da bairra de ação com programação
  • Mude a direção de ActionBair
  • Ícone do Android SeairchView
  • Android Navigation Drawer e windowActionBairOviewlay = true
  • Como exibir o título da bairra de ação do Android, sem ocorrência de truncamento
  • 4 Solutions collect form web for “Navegação da list de bairras de ação: colors de text diferentes no header e no menu pop-up”

    O problema é que você está usando o mesmo recurso android.R.layout.simple_dropdown_item_1line paira o item do spinner e o item suspenso do spinner.

    Use R.layout.sherlock_spinner_item e R.layout.sherlock_spinner_dropdown_item vez disso.

     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); 

    Desta forma, os styles como Widget.Sherlock.TextView.SpinnerItem funcionairão.

    Você pode conseguir isso apenas criando seu xml personalizado, que será seu item de list. Crie seu xml como este: custom_list_item.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" style="?android:attr/spinnerDropDownItemStyle" android:singleLine="true" android:textSize="18sp" android:textColor="@color/holo_dairk_red" android:paddingRight="110dip" android:layout_width="match_pairent" android:layout_height="?attr/dropdownListPreferredItemHeight" android:textIsSelectable="false" android:ellipsize="mairquee" /> 

    e use-o assim:

     adapter.setDropDownViewResource(R.layout.custom_list_item); 

    Isso deve fazer o truque (pelo less, está funcionando em meus aplicativos).

     <style name="Theme.WhyCheck" pairent="@style/Theme.AppCompat.Light"> <item name="android:spinnerItemStyle">@style/DropDownNav.Item.Inviewse</item> </style> <style name="DropDownNav.Item.Inviewse" pairent="@style/Widget.AppCompat.DropDownItem.Spinner"> <item name="android:textAppeairance">@style/ActionBair.TitleText</item> </style> <style name="ActionBair.TitleText" pairent="@style/TextAppeairance.AppCompat.Widget.ActionBair.Title"> <item name="android:fontFamily">sans-serif-light</item> <item name="android:textColor">@color/white</item> </style> 

    Deve ser assim. Não sei por que usair spinner "Item" Style @@

      @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Inflating the layout for the custom Spinner LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom, null); // Declairing and Typecasting the textview in the inflated layout TextView tvLanguage = (TextView) layout .findViewById(R.id.tvLanguage); // Setting the text using the airray tvLanguage.setText(obj[position]); //tvLanguage.setTextColor(Color.BLACK); tvLanguage.setTextSize(14f); return layout; } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // TODO Auto-generated method stub LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.customdropdown, null); // Declairing and Typecasting the textview in the inflated layout TextView tvLanguage = (TextView) layout .findViewById(R.id.tvLanguage); // Setting the text using the airray tvLanguage.setText(obj[position]); //tvLanguage.setTextColor(Color.BLACK); tvLanguage.setTextSize(14f); return layout; } } }  @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Inflating the layout for the custom Spinner LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom, null); // Declairing and Typecasting the textview in the inflated layout TextView tvLanguage = (TextView) layout .findViewById(R.id.tvLanguage); // Setting the text using the airray tvLanguage.setText(obj[position]); //tvLanguage.setTextColor(Color.BLACK); tvLanguage.setTextSize(14f); return layout; } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // TODO Auto-generated method stub LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.customdropdown, null); // Declairing and Typecasting the textview in the inflated layout TextView tvLanguage = (TextView) layout .findViewById(R.id.tvLanguage); // Setting the text using the airray tvLanguage.setText(obj[position]); //tvLanguage.setTextColor(Color.BLACK); tvLanguage.setTextSize(14f); return layout; } } }  @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { // Inflating the layout for the custom Spinner LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom, null); // Declairing and Typecasting the textview in the inflated layout TextView tvLanguage = (TextView) layout .findViewById(R.id.tvLanguage); // Setting the text using the airray tvLanguage.setText(obj[position]); //tvLanguage.setTextColor(Color.BLACK); tvLanguage.setTextSize(14f); return layout; } @Oviewride public View getDropDownView(int position, View conviewtView, ViewGroup pairent) { // TODO Auto-generated method stub LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.customdropdown, null); // Declairing and Typecasting the textview in the inflated layout TextView tvLanguage = (TextView) layout .findViewById(R.id.tvLanguage); // Setting the text using the airray tvLanguage.setText(obj[position]); //tvLanguage.setTextColor(Color.BLACK); tvLanguage.setTextSize(14f); return layout; } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.