Divider lines in overflow menu - android

Is it possible to put divider lines between groups of menu items in an overflow menu in Android?
Dividers are a standard feature of menus, and have been for at least 30 years. So it seems a bit weird if this isn't possible in a non-trivial way.
For example, the Chrome menu on OSx looks like this:
I'm talking about the lines between some of the menu items. Is there a way to get something similar in the overflow and/or context menus in Android without resorting to custom views and whatnots?

Related

Positioning labels in Android menu

I'm trying to position labels in menu like on following drafts. It should behave like standard android menu - with showAsAction="ifRoom". Everything I want is positioning labels under icon when item is in actionbar and positioning labels next to icon, when in dropdown menu.
So far I tried multiple menus definitions - with separating resources into *-land and *-port, searching android-arsenal, but without any luck. Is it possible to do that with 'official' android menu implementation or is there any 3rd party library for that? Writing my own implementation is the last resort.

3 dot/settings in top bar buttons

When in some apps, there are those 3 dots in the top right of the app, on the action bar (not the home buttons), which allow for more options. In my app I have on, but I do not know how to make it do a method when it is clicked. Do I use android:onClick="METHOD_NAME ? Or do I need to setup a button variable in my activity class and setup and onClickListener? I have already tried both but I may be doing something wrong.
That three dots are the menu in the action bar. They are always shown on devices without a menu key.
See also the documentation for more details.
Three dots are called Overflow(very aptly named) and to use them you need to use ActionBar which is the top long, horizontal bar showing icons, other buttons along with the Overflow button.
Now in some devices where there is no physical menu button you will always see Overflow button.
Go through Docs and tutorials related to ActionBar but keep one thing in mind that ActionBar is only available for devices with android above HoneyComb. For android devices below 3.0 such as GingerBread or Froyo you will have to use compatibility libraries, so that will be an additional task.
And most notable libraries for this purpose are ActionBarSherlock and AppCompat.

Custom Overflow Menu Outside of ActionBar

I need to implement a custom overflow menu with menu items and the overflow icon if the screen size cannot show all the icons. I cannot use a side scroll since I am already inside an expanded list view. I cannot use the Top or bottom action bar menu because the action will change based on what list item has been expanded.
So I would like to create my own overflow menu - similar to the gmail screenshots attached
Any ideas? Apparently ABS can be used for this but I can't figure it out, please help :)
ListPopupWindow is what you're looking for. It's an API 11+ class, however. ABS includes a backported version which is basically just a ListView inside a PopupWindow (both API 1 classes).

How to make a actionbar drop-down-menu that shows items horizontally?

I want to make a action-bar drop-down-menu that shows items (icons) horizontally. Like this:
This is suppose to be a action-bar withe drop-down menu, where you can choose a color.
So it should show the icons (colors) horizontally and the icons should be clickable. Until now I have only managed to make a vertical list.
If possible I would like to do this in XML.
The ActionBar is not designed for such a use-case. The ActionBar buttons are meant to replace the old options menu that could be triggered with a separate hardware button on older devices (pre HC/ICS). The overflow button (the one with the 3 dots) that you've drawn in your sketch is used when there isn't enough room to show all buttons (the Android framework takes care of this automatically), so those will be grouped in the overflow menu. Overriding this behavior is a bad idea (if even possible).
Instead you should consider another approach: Add one ActionButton to the ActionBar that is meant to handle the color chooser. When this button is clicked the best solution is to show an AlertDialog (you can easily insert your on Views here that show the colors you want) because this will work best even if the button is hidden in the overflow menu.
Alternatively you could trigger a PopupMenu or implement some QuickAction to handle the color chooser (this will probably suck if your button is hidden in the overflow menu and will also lead to a very confusing UI).

How to make an overflow menu like in Chrome?

I would like to make an overflow menu similar to the chrome app in android in which it has the forward, backward and bookmark buttons inside it.
This is the overflow menu in the chrome app.
Any ideas?
You can't have custom views for your overflow menu items, so Chrome is not using the standard action bar. It's weird that Google doesn't even use its own standard tools that it pushes for everyone else to use, but that's just how it goes.
If you load up an app that uses the real standard ActionBar (for example, Calendar or Messaging), it'll have a view in the hierarchy called an ActionBarContainer and you can follow it down all the way to the overflow button, which is an ActionMenuPresenter$OverflowMenuButton.
But load up Chrome in the Hierarchy Viewer, and you'll find out that what they use for the overflow button is just an ImageButton.
Obviously you can either make your own full-on ActionBar implementation, or add an overflow button to the existing ActionBar and somehow make sure the real overflow button never gets displayed. You might find the ActionBar compatibility sample project useful in making a fake actionbar. Either way, if you again look in the Hierarchy Viewer, they're just using a PopupMenu to display the menus in both the real ActionBar apps and the Chrome app.
Hopefully that helps enough to get you started.
Have a look to Android ActionBar for the whole component.
For the sole layout, you can inflate any layout and place it anywhere you want...

Categories

Resources