Android - ActionBarSherlock - Set textcolor of text in menu

前端 未结 2 1323
无人共我
无人共我 2020-12-19 11:21

I want to change white color of text to orange.

Here is a example.

\"ActionBarSherlock\"

相关标签:
2条回答
  • 2020-12-19 12:03

    This can be done through setting some styles for your action bar. It is explained in this blog post http://android-developers.blogspot.com.au/2011/04/customizing-action-bar.html

    You need to set this in your style for you app.

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

    Then you can specify this style with your own text color.

    <!-- 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>
    
    0 讨论(0)
  • 2020-12-19 12:08

    You can change the color of the MenuItem text easily by using SpannableString instead of String.

    @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);
    }
    
    0 讨论(0)
提交回复
热议问题