2012-05-25 57 views

回答

3

這可以通過設置一些樣式你的動作條來完成。這是在這篇博文中解釋http://android-developers.blogspot.com.au/2011/04/customizing-action-bar.html

你需要爲你的應用程序設置你的風格。

<style name="MyTheme" parent="android:style/Theme.Holo.Light"> 
    <item name="android:dropDownListViewStyle">@style/MyDropDownListView</item> 
</style> 

然後,您可以使用自己的文本顏色指定此樣式。

<!-- style the items within the overflow menu --> 
<style name="MyDropDownListView" parent="android:style/Widget.Holo.ListView.DropDown"> 
    <!-- This is the orange text color --> 
    <item name="android:textColor">#CC3232</item> 
</style> 
+3

那麼這實際上不適合我。這裏的DropDown Item只有後臺選擇器。 – redestructa

+0

適合我!我實際上是在Xamarin Android中開發的,我一直在尋找這個解決方案。經過無數谷歌搜索,我終於絆倒了這一點,並嘗試它,它的工作就像一個魅力。你不知道這個子菜單最終會變成藍色的哈哈。 – TeamChillshot

-1

這沒有改變文字顏色,只有Backgorund顏色

1

您可以輕鬆地通過使用SpannableString代替String改變MenuItem文本的顏色。

@Override 
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { 
    inflater.inflate(R.menu.your_menu, menu); 

    int positionOfMenuItem = 0; // or whatever... 
    MenuItem item = menu.getItem(positionOfMenuItem); 
    SpannableString s = new SpannableString("My red MenuItem"); 
    s.setSpan(new ForegroundColorSpan(Color.RED), 0, s.length(), 0); 
    item.setTitle(s); 
}