For my application I need something like a Quick Action. There are plenty of useful libraries on github since this seems not to be a feature that is officially available via the Android SDK.
But I just stumbled across something in the official gmail app:
This (the dropdown menu) is exactly what I need for my application. But I'm wondering what the the best way to achieve this functionality is. An own Quick Action implementation? Some weird Button+Spinner meet up? Are there any libraries or design guidelines that may help me on creating such a widget?
The proper way is to use contextual action items (action modes). That will show action items in the action bars when you long-press an item. If you have more than fit on the action bar, they will be displayed in the overflow just as with regular action items.
http://developer.android.com/design/patterns/selection.html
That's the ActionBar overflow menu. The actions in there are normal MenuItem's configured to be organized on the overflow menu if there's not enough room to display them all
Here's the action bar documentation where you can find how to show/hide the MenuItem. Basically, you need to play around with the android:showAsAction xml attribute when defining your action bars.
android:showAsAction=["ifRoom" | "never" | "withText" | "always" | "collapseActionView"]
The widget used in the shown gmail application is a PopupMenu (introduced in API 11). It's behavior is documented and explained in detail here.
Related
I am an intermediate android developer and i have an app that should have a custom designed action bar.I have researched and noticed that skype uses a customised action bar at the top.How did they implement that?I only need pointing to the right direction and the rest i can do myself.
Below is a screenshot of the skype design am talking about.
I am posting this for anyone who might find it helpful.The action bar in android is a bit rigid and doesn't offer a developer much freedom for styling it.Instead style the window title bar to suit your design taste. That's how i achieved my design.
Tutorials on how to do that are all over the internet,and the best thing about it is its really simple.
I am reading about action bars in BusyCoder's Android guide. There is an example:
<item
android:id="#+id/add"
android:actionLayout="#layout/add"
android:icon="#android:drawable/ic_menu_add"
android:showAsAction="ifRoom"
android:title="#string/add"/>
What is the point to have both android:actionLayout and android:icon defined? What are the conditions when the icon would show up?
Thanks for helping out Android noob
What are the conditions when the icon would show up?
I can't rule out the possibility that the action bar will decide that there is not enough room for the actionLayout, but there is enough room for an action item, which would therefore show the icon. Also, with ActionBarSherlock, the icon is shown even in the overflow on Android 2.x devices, and so again if the actionLayout would be too large, the icon might get used. Also, if I used ifRoom|collapseActionView instead of just ifRoom, the icon would be used.
That being said:
My sample does not actually watch for this theoretical action item, should it appear, to do anything if the user clicks on it
I am guessing at possible action bar behavior, as I have not tried any experiments to force the action bar to decide whether there is enough room for all actionLayout-configured items
here android:icon is defined to supply an icon for your menu item. This is always optional but it is recommended to have an icon for the menu item.
android:actionLayout is defined to supply a custom view for the menu item again this is optional but if u need some Image Views, Text Views, Edit Text Views etc. in your menu item, this is the way to go.
If you need more help see these guides. These I think will be more helpful to you.
Action Bar Android Developer Guide
Menu Resource Android Developer Guide
Also take a look at this example. This may give you a much better idea about android Action bars.
vimaltuts.com/android-tutorial-for-beginners/android-action-bar-tab-menu-example
Thank You!
I want to show Action Bar like below.
I have already used this library clickhere
But it takes only two icons on Action Bar. If I add four items, then last two are shown me like menu. I want all in Action bar same as image above.
Is it possible? if yes, then HOW? Can I change Action Bar color or its default style available in Device?
Thanks in Advance.
I recommend you use this:
http://jgilfelt.github.com/android-actionbarstylegenerator/
to style your ActionBar.
If you want all the 4 icons to be there, just add this attribute to all the menu items:
android:showAsAction="always"
hello try this library
it sure help you And you may have to add you own logic to handle this in below 2.3 Android OS and above 3.0 Android OS.
there is many demo sample available like below :
There is no way you can be sure of the number of icons displayed in the action bar. There is a large varierty of Android devices out there and they all have different screen sizes. That's why you have to prioritize the actions available in a menu : the most important will be displayed as actions in the action bars and the others will be displayed in the "menu" : the action overflow.
You should think of actions in a functional way, not a graphical way.
With ref to Image that you attached you should decide which design pattern you want to use in your application, there are many UI patterns available for mobiles, tablets. The image you attached looks like Side Navigation UI pattern. It's better you decide which UI pattern perfect for your app.. then start implementing it with custom action bar libs (if you want action bar in less than Android 3.0 ver) or any other.
I want to create custom options menu as below and also want this to be available on all activities.
So far I am able to add options menu using onCreateOptionsMenu method, and setting its icons.
But have no idea how it can be inflated as shown in images.
After doing some google search found out one example . If can get more help on implementing custom options menu.
Neither of those are options menus. If they happen to be triggered by pressing a MENU button, then those apps are monitoring onKeyDown() for MENU button presses. This also means that their menus will not work on devices that lack such a MENU button.
I strongly encourage you to follow the Android design guidelines. I recommend that you start integrating an action bar and using action items and the action overflow area, perhaps leveraging ActionBarSherlock to support Android 2.x devices.
I'd like to create a navigation menu in my Android app: a bar always at the bottom of the screen, with 4 choices Home|Categories|Search|Favorites, and the current page highlighted.
It seems the options menu can hardly be customized, so I can't use it.
Do I have to add this navigation bar in every layout or is there any better solutions?
Thanks
Julien
It sounds like you're replicating an iPhone interface. As most Android phones have buttons along the bottom of the screen (Home, Back, etc) it's likely to be a bad idea to put navigation there as it's easy to hit the wrong one.
The Google-recommended approach is to use the Action Bar pattern, across the top of the screen, which is very clear, and means your app is consistent with others (look at Twitter, Google Maps, Facebook - they all use the action bar pattern).
From Honeycomb (v3.0) onwards:
http://developer.android.com/reference/android/app/ActionBar.html
A simple library to create an Action Bar on any version of Android
https://github.com/johannilsson/android-actionbar
To create an action bar that uses that library on versions earlier than 3.0, but uses the official implemention for v3.0+, try this:
https://github.com/JakeWharton/ActionBarSherlock
The action bar is highly customisable, but remember that a key to a nice user interface is consistency across the platform, i.e. your app consistent with other apps and the OS.
If you need a navigation with more items or items within a specific page, you can use TabLayout, but for your primary nav, use the action bar, that's what it's for.
Use the TabLayout