Skip to content Skip to sidebar Skip to footer

Is There A Standard Way To Add Dividers Between Action Bar Items In Android 3.0?

I have a slight problem trying to customise the look of the action bar in my app. I want to be able to have the pixel wide dividers to group action bar items that you see in many o

Solution 1:

I wouldn't try and force dividers into places that the system does not add them automatically as it will make your app inconsistent with the platform. The default behavior is:

  • Divider between overflow and others.
  • Divider between text and another item where it would disambiguate which item the text belongs to.

Solution 2:

I couldn't find a standard way, but the way I did it was to use the android:actionLayout property for the menu item, and I put the divider in there.

Solution 3:

When Google released the 3.0 SDK I got a quick demo app to see how the ActionBar works and just looking back at it, if I use Text Items without Icon drawables, then I get automatic dividers drawn.

My menu.xml file is like this:

<menuxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:id="@+id/menu_text"android:showAsAction="ifRoom"android:title="@string/action_label_text" /><itemandroid:id="@+id/menu_text"android:showAsAction="ifRoom"android:title="@string/action_label_text" /><itemandroid:id="@+id/menu_text"android:showAsAction="ifRoom"android:title="@string/action_label_text" /><itemandroid:id="@+id/menu_text"android:showAsAction="ifRoom"android:title="@string/action_label_text" /></menu>

Maybe this won't work with icons??

Or thinking about it, maybe the size of the icon has an effect?

Post a Comment for "Is There A Standard Way To Add Dividers Between Action Bar Items In Android 3.0?"