Set max button space in ActionBar before overflow - 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.

Related

How to set padding on menu icon in action bar on API Level 9 and 9+?

I want to add two menu icon in action bar, but there's some extra space taken between them, and in this case, the app name not shown fully and also looking not good...
How can I omit these extra space around icons by setting padding or other way?

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).

Is there a way of increasing width of Action Bar drop down list

I have run though various scenarios and I haven't been able to find a solution.
The issue arises when the orientation of the device is switched to landscape. The tabs become a spinner. The spinner isn't using the available space with in the action bar and it starts ellipsing the items, and visually it looks ridiculous as you can see:
new users cant post images,users can only post a maximum of two hyperlinks. you should inform the user before
http://i.imgur.com/1gW8F.png
switching to another item on the spinner for tabs:
i.imgur.com/I8PQ5.png
I was only able to find one built in style item for the action bar drop down list : android:actionDropDownStyle .
But it only seems to control whether to show a drop down or dialog
developer.android.com/reference/android/widget/Spinner.html#attr_android:spinnerMode
Even overriding the style and adding layout_width made no difference.
There is also no drop down item style like found in the spinner android:spinnerItemStyle. But the items are being styled based on the
android:actionBarTabStyle and android:actionBarTabTextStyle, but overriding those styles and adding layout_width made no difference.
But after reducing the number of tabs from 3 to 2, the width increased.
http://i.imgur.com/26iZN.png
but clicking on the second tab, made the action bar switch back to spinner, but this time more spaced is used and completed is not ellipsed
i.imgur.com/3949m.png
It's as if the width of the spinner is being determined by the number of tabs. This does seem poorly done, it could be from the fact they are measuring if there is space to show the tabs bar. And when there isn't space, they are not recalculating the width available, and are just using the individual tab width they calculated earlier.
This was done on ICS, and with the display of title turned off, in the hope of increasing more width available for the action bar spinner.

Customizing Bottom Action Bar in Android

I want to use the split Action Bar - one on top, one on bottom. I know you can call it with this:
uiOptions="splitActionBarWhenNarrow"
My 2 questions are simple concepts:
I would like only two items on the bottom; one on far left, one on far right. Is this possible? It seems to be almost an overflow and pushes everything up top -- down to the bottom. Is there a way to control what items will show up on which bar?
Also, I have holo.light.darkactionbar theme. Yet, for the bottom bar, it keeps the light background AND the white text so you can not see the icons - is it possible to apply dark background like the top bar?
I would like only two items on the bottom; one on far left, one on far right. Is this possible? It seems to be almost an overflow and pushes everything up top -- down to the bottom. Is there a way to control what items will show up on which bar?
Unfortunately not. All action items will be pushed on to the bottom bar when using the split action bar. One way to get around this would be to not use the split action bar, and have a custom view at the bottom holding buttons for all the items you want at the bottom. You'd probably be able to emulate the style of an split action bar fairly well using themes.
Also, I have holo.light.darkactionbar theme. Yet, for the bottom bar, it keeps the light background AND the white text so you can not see the icons - is it possible to apply dark background like the top bar?
This sounds odd and isn't standard behaviour (both bars are dark in my app), are you using a custom theme? If you want to override this manually, define a theme with a custom android:backgroundSplit value as shown on the Android Developers website.

How can I determine the relative position of option menu objects in the Android ActionBar?

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.

Categories

Resources