Search code examples
androidandroid-actionbaractionbarsherlockandroid-holo-everywhere

Force overflow menu in ActionBarSherlock


I want the 4.0+ overflow menu to be used on pre ICS devices (2.3 - 2.1). I'm using HoloEverywhere with ActionBarSherlock.

I tried the following solution:

ActionBarSherlock & HoloEverywhere - Forcing Overflow?

but it does not work because absForceOverflow does not exist. Was it removed in the newest version or something? I've checked the R files of both ABS and HE library projects and the field is simply not there.

My app's theme is set to @style/Holo.Theme.Sherlock.Light and that is the theme that i was trying to inherit from and add the absForceOverflow parameter set to true.


Solution

  • If you are using Version 4.2.0, then .ForceOverflow themes have in fact been removed.

    Source: Version 4.2.0 Changelog

    Extract of the Change Log:

    Add SearchView widget for standard search interaction (API 8+ only)
    Fix: ShareActionProvider in the split action bar no longer fills the entire screen.
    Fix: ShareActionProvider now does file I/O on a background thread.
    Fix: Automatically correct ColorDrawable not respecting bounds when used as a stacked background.
    Fix: Ensure fragments collection is present before dispatching events.
    Fix: XML-defined onClick searches the correct context for the declared method.
    Fix: Ensure action mode start/finish callbacks are invoked on the activity for the native action bar.
    Fix: Allow tab callbacks to have a fragment transaction instance for any FragmentActivity.
    Fix: Ensure CollapsibleActionView callbacks are dispatched in both native and compatbility action bars.
    Fix: Remove .ForceOverflow themes. These never should have been included.
    

    If you absolutely need to force Overflow, you will need to download an earlier version of ABS. You can get a list of download as per their release history here: http://actionbarsherlock.com/download.html

    I personally still use the ABS version 4.1.0 since I do not currently want to make ancillary changes in my app. I also use this in my theme.xml:

    <style name="MyTheme" parent="@style/Theme.Sherlock.ForceOverflow">
        <item name="android:windowBackground">@color/background</item>
        <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
        <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
    </style>
    
    <style name="MyTheme.ForceOverflow">
        <item name="absForceOverflow">true</item>
    </style>
    

    And while applying a theme for an Activity in the manifest.xml, I use this as the attribute: "@style/Theme.SociallyYOU"

    Again, if you must absolutely force overflow, you might also want to read CommonsWare's thought on the same in another question here: https://stackoverflow.com/a/12872537/450534.

    NOTE: That being said, it is always better to use the latest version if the trade offs aren't to critical. By posting how I force the overflow menu, I am neither suggesting that you use an older version nor do I recommend that. It is merely informing you of the possibilities.