Light.DarkActionBar menu item text colour unchangeable?

后端 未结 6 965
轻奢々
轻奢々 2021-02-01 19:34

The application I\'ve been developing uses ActionBarSherlock, and the main theme inherits from Theme.Sherlock.Light.DarkActionBar. The design requires that the overflow menu pop

相关标签:
6条回答
  • 2021-02-01 19:40

    For me this solves the problem, try this instead:

    <style name="MyTheme" parent="Theme.Sherlock.Light.DarkActionBar">
        ...
        <item name="actionBarWidgetTheme">@null</item>
        <item name="android:actionBarWidgetTheme">@null</item>
        ...
    </style>
    
    0 讨论(0)
  • 2021-02-01 19:48

    In my research I haven't found a way to change the text color, but you can at least handle hardkey menus gracefully.

    This link provided me with a passable solution to the problem: https://github.com/jgilfelt/android-actionbarstylegenerator/issues/30

    Commenting out the "android:panelBackground" item from my generated theme allowed the text to at least be visible on hardkey menus, even if it doesn't perfectly match the theme.

    You could also try replacing the "menu_hardkey_panel_whatever.9.png" drawable with something that will work for your theme and the black text.

    0 讨论(0)
  • 2021-02-01 19:48

    I think that due to the fact that Theme.Sherlock.Light.DarkActionBar don't style its contents right is due to the actionWidgetTheme attribute is used with a ContextThemeWrapper for inflating the action bar views (Jake Wharton's own words), thus something like the following (not tested) will be needed to fulfill your needs, though breaking your need of not using Theme.Sherlock as parent in one way:

    <style name="MyColorTheme" parent="Theme.Sherlock">
        <item name="android:actionMenuTextColor">@android:color/white</item>
        <item name="actionMenuTextColor">@android:color/white</item>
    </style>
    
    <style name="YourMainTheme" parent="Theme.Sherlock.Light.DarkActionBar">
        <item name="android:actionMenuTextAppearance">@style/MyColorTheme</item>
        <item name="actionMenuTextAppearance">@style/MyColorTheme</item>
    </style>
    

    Might work or not work. That's the question :)

    0 讨论(0)
  • 2021-02-01 19:49

    Not entirely sure about this, but I believe the pop-up menu uses the same styling as the overflow menu. In which case you'd just do something like this.

    <item name="android:itemTextAppearance">@style/your_new_text_appearance</item>
    
    <style name="your_new_text_appearance">
        <item name="android:textColor">@android:color/white</item>
    </style>
    
    0 讨论(0)
  • 2021-02-01 19:52

    I found the solution, use:

    getSupportActionBarContext()
    

    e.g.

    ArrayAdapter<CharSequence> list =
                ArrayAdapter.createFromResource(getSupportActionBarContext(), R.array.navigation, layout.simple_spinner_item);
        list.setDropDownViewResource(layout.simple_spinner_dropdown_item);
    
        getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        getSupportActionBar().setListNavigationCallbacks(list, this);
    
    0 讨论(0)
  • 2021-02-01 19:53

    Giving it a chance: there is a text appearance called actionMenuTextAppearance. Have you tried that?

    Update: I did some more digging and I believe that this file is the layout And there they refer to textAppearanceListItemSmall and textAppearanceSmall. However, it takes this value from a special theme which is specified as following in Theme.Holo.Light

    <item name="panelMenuListTheme">@android:style/Theme.Holo.Light.CompactMenu</item>
    

    And like this in Theme.Holo:

    <item name="panelMenuListTheme">@android:style/Theme.Holo.CompactMenu</item>
    

    The problems comes from the fact that the parent of Sherlock.__Theme.DarkActionBar is Theme.Sherlock.Light. This is not valid for the dark action bar. Taking the line from Theme.Holo should do the trick.

    0 讨论(0)
提交回复
热议问题