I'm using ActionBarSherlock to implement an actionbar in my Android application. Menu options that don't fit on this actionbar are automatically added to the overflow menu.
The problem I'm facing is that these menu options have center alignment:
How do I make sure that the menu items in the overflow menu are right-aligned, like for example in the Gmail application?
Thanks.
Never mind, I found the cause.
It turns out I was styling TextView somewhere in my theme with
<item name="android:gravity">center_horizontal</item>
and this also affected the menu items.
Related
Per usual my ActionBar has a number of menu items that I set as app:showAsAction="never". So when user clicks on the overflow button, these items show up but they don't have icons. How do I force the icons to show? The answer at Is it possible to display icons in a PopupMenu? does not answer my question as it is concerned with the popup menu. When I tried to apply it to my case it shows all items not just the ones in the overflow. Also I am anchoring it in the toolbar as I don't know how to get the overflow view.
I don't think there is a simple way to toggle showing an icon in the action bar overflow menu. But I did find that someone was able to create a fully customized overflow menu:
http://keepsafe.github.io/2014/11/19/building-a-custom-overflow-menu.html
First of, I'm using SherlockActionBar.
I've one MenuItem that is 'always' showed in the ActionBar and one other MenuItem that is only showed 'ifRoom'. There are also other MenuItems that are 'never' showed in the ActionBar and therefore there exists a Overflow Icon (if device has no hardwarebutton).
My question now is, how am I able to tell if the MenuItem with 'ifRoom' is currently showed or not in the ActionBar (in ActionBar or Overflow?)? I need to know that because I'm using the ShowcaseView Library to highlight these options. Therefore I have to know if I should highlight the Overflow or I can directly target to the MenuItem.
Thx
Imo there is no way to know if a menu entry is on the overflow menu via an API.
Even with "never" you can still be pushed into the overflow menu when the the title is long and your device is very narrow.
What you could try is to place an action view into your menu items and get its position on screen. If not on screen you can be certain it is pushed into the overflow menu.
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).
I was wondering if it is possible to put items directly in the overflow menu on the actionbar. I am using ActionbarSherlock for my app (if this is relevant). I have several menu items, for instance: Add, Delete, Sort, About app, etc. These are all items for my actionbar menu. I would like to leave only "Add" outside, and put the rest in the overflow menu. Is there any way to do that?
I was wondering if it is possible to put items directly in the overflow menu on the actionbar.
Yes, set the attribute showAsAction to "never":
<item android:id="#+id/item"
android:title="#string/item"
android:showAsAction="never"/>
Instead of using an ActionLayout to replace the ActionBar when pressed a MenuItem. I want that ActionLayout to overlap on the ActionBar.
Since most of the applications use this behavior I thought its the standard SearchView widget.
And since my application is for API 10 and more, i couldn't use SearchView, hence used latest ActionBarSherlock library(4.2.0), where Jake added SearchView.
The problem is, even here its like replacing the initial menu items with the ActionViewClass.
The reason i want the ActionLayout to overlap but not replace the ActionBar is, I need to have 3 MenuItems in the ActionBar and if i keep all of them as
android:showAsAction="always|collapseActionView"
they are even visible when ActionLayout is shown, which gives little width for the ActionLayout
if i am using
android:showAsAction="ifRoom"
the last icon is missing. Only 2 icons are visible.
Thank You
If you are having physical menu button (e.g. Nexus S) in your device then the dot line will not show. When you press the Menu button it’ll show up.
You may use something as this Use android:showAsAction="never" to force an action item into the overflow.