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 of the native apps (e.g. Gmail, Calendar). I found a way to do this by adding a menu item and setting the 'android:actionLayout' attribute to a custom layout for the divider:
<View
android:background="@color/LightGray"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:layout_width="1dip"
android:layout_height="fill_parent" />
This works nicely, but the issue is it counts as a menu item and the action bar seems to limit the number of menu items to 4 - any others get pushed into the overflow menu.
So I guess what I'm asking is whether there is a standard way to add item dividers without having to use a menu item with a custom view, and in a way that doesn't count towards the limit for action bar items?
Thanks in advance!
All action buttons and other items available in the action overflow are defined in an XML menu resource. To add actions to the action bar, create a new XML file in your project's res/menu/ directory. The app:showAsAction attribute specifies whether the action should be shown as a button on the app bar.
Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button. In general an ActionBar consists of the following four components: App Icon: App branding logo or icon will be displayed here.
In Android applications, ActionBar is the element present at the top of the activity screen. It is a salient feature of a mobile application that has a consistent presence over all its activities.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With