Is there any way to check how many buttons are visible, and how many are hidden in overflow?
Because, like we all know, depending on the device, a different number of buttons fits in ActionBar.
Why do I need it? I'm trying to place an arrow which will point to a particular action button. And to place it correctly, I need to know if this button is hidden in overflow, or is 3rd from the right edge?
Is there any way to check how many buttons are visible, and how many are hidden in overflow?
I don't think so. AFAIK, isVisible() will return true for items in the overflow area, as that is tied to the separate "visibility" aspect of a MenuItem.
I'm trying to place an arrow which will point to a particular action button. And to place it correctly, I need to know if this button is hidden in overflow, or is 3rd from the right edge?
No, you would need to know the pixel coordinates of the button, which will vary based on a number of factors, above and beyond whether or not it is in the overflow area, such as actual screen density.
Related
I am working on an Android application and have to code up the following design for one of the screens:
(Ignore the yellow stuff, I have just masked the Logo and the App-specific information for now)
My question is: How do I design this particular type of screen? The top pane is akin to an ActionBar in Android. However, when any button on the top pane is hit, this custom "popup" having a rectangular form with a small arrow on top pointing towards the button is display and does not interrupt the current/main activity.
I have looked around, but still dont understand how to accomplish this.
Any thoughts? Thanks!
You can use the native Action Bar along with the icons.
The only problem is if you want to show them all at once.
Some icons may be hidden depending on the size of the phone.
As for the custom pop-up, the toast feature is available to do that.
It is quite easy to adjust the position of toasts and customise toasts :
Customisation of toasts: http://developer.android.com/guide/topics/ui/notifiers/toasts.html#CustomToastView
Changing postion of toasts: How to change position of Toast in Android?
A devices with the specs of Nexus 5 shows only two button in action bar when is in portrait mode if I use ifRoom as attribute, the others entries are shown in overflow as action, this despite there is enough space to show at least 4 buttons
How could I set the amount of space reserved to buttons in action bar before overflow?
Why need to set some amount of space when all you need to do is use always attribute instead of if room.
Of course this would also show limited buttons(maybe 4 at max) according to screen size.
Otherwise if you want greater control regarding spacing and all I guess your best bet would be to use your own variant of action bar. I would explain how I did that.
First of all use theme NoActionBar or hide default action bar in activity after super.onCreate method.
Then simply add a view at the top with your app icon in the corner, overflow button in right corner, and your buttons in between.
Also for Overflow menu you will have to use popUpWindow.
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).
I have an application with multiple pages, all of which will be using the ActionBarSherlock on top and on the bottom. The top bar will not have any actions, all actions will be held in the bottom bar.
Every page on in my application uses 2 actions, but some also have other actions. Therefore, some pages will need the action overflow and some will not.
I want to keep the 2 actions that are always used all the way to the right to ensure that they are in the same place on every page, with the overflow button appearing in the middle sometimes.
I want to keep the 2 actions that are always used all the way to the right to ensure that they are in the same place on every page, with the overflow button appearing in the middle sometimes.
You can't do that, sorry. When present, the overflow button will always be the furthest to the right.
Overflow button is always to the right. But since it's so small, I wouldn't worry about it affecting your UX, as long as you always use a consistent order for your permanent actions.
In the Honeycomb ActionBar, I am trying to determine the position of the icons that appear as my ActionBar's 'showAsAction' options. Several of my icons are set to appear only if there is room. I want to include helpful comments under each icon when the application is first run. To properly position the comments , I need an idea of where these icons are.
I have called getActionBar() from the activity and the icons don't appear in the ActonBar's View. I know I can get a handle on the Menu Item through the onPrepare and the onCreate for the OptionsMenu, but they don't contain any positioning information since the ActionBar has not been rendered. Any ideas? I have also explored the onMenuVisibilityListener, but the ActionBar at that point still does not contain any information that I can use to calculate the relative positions of the option menu icons.
If there is a way to also just determine which actionbar items are actually appearing, I can calculate where to place things too.
I want to include helpful comments under each icon when the application is first run.
Then load a different menu XML resource on the first run, one that has withText along with ifRoom for android:showAsAction.
You could make this a configuration option for the user, so the user gets to choose which style to use.
If there is a way to also just determine which actionbar items are actually appearing, I can calculate where to place things too.
Except that you can't actually place anything there. The toolbar buttons take up the full action bar height.