Search code examples
androidactionbarsherlock

action bar takes up entire screen


I am using Action Bar Sherlock for compatibility with earlier versions of Android. My objective is to not display the app title in the action bar, but to show a logo on the left and a couple of action buttons on the right. In my styles, I am using these options for the action bar:

<style name="MyActionBarStyle" parent="Sherlock.__Widget.ActionBar">
    <item name="background">@drawable/toolbar</item>
    <item name="displayOptions">showHome|useLogo</item>
    <item name="android:background">@drawable/toolbar</item>
    <item name="android:displayOptions">showHome|useLogo</item>
</style>   

Everything works as hoped for on Android 2.3. On my Android 4.0.4 test phone, however, the action bar takes up the entire screen, with the app logo on the left, the action buttons on the right, but these are all centered vertically on the screen instead of residing at the top. The gradient for the toolbar, which is actually a very small pic dimensionally, occupies the entire screen (besides the status bar). The rest of the activity below the action bar is not visible.

If I remove showHome from the displayOptions above, the action bar no longer takes up the whole screen. But my logo is now gone. What do I need to do to get this working properly for Android 4?

Thanks in advance for any help.


Solution

  • I determined that this issue is not a problem with ActionBarSherlock, just with Android 4 in general. There seems to be a combination of options that causes this behavior to happen. I couldn't find a satisfactory solution with styles but was able to get the desired behavior in code.