Android toolbar show as much as possible menu itemes (without title) - android

Is there any way to customize the Android toolbar to show as much as possible menu items.
Because this is depends on the screen dpi to show number of the items.
So what I'm looking for is to fill as much as possible of the items and for the rest to be in the popup menu.

On your menu item use this android:showAsAction="always" to show only icons. This could land you into few issues so using android:showAsAction="ifRoom" could be much better if you have less space and more icons to be showcased to the user on the toolbar.And ifRoom adjusts automatically if there is space left on the toolbar with various screens as well as with the portrait and landscape views perfectly fine.

Related

How to allow more visible items on a menu in android before collapse?

Today, even in a large screen tablet, the menu items appear to be limited to 5 items and then it collapses. But I would like to use more space and show more icons.
Is there a easy way to achieve that? Or should I extend and customize the android.view.Menu in some way?
Thanks
The action bar is designed have a finite maximum of action items based on the device's density-independent width. The action items can also not cover more than half the width of the action bar.
See this answer.

Set max button space in ActionBar before overflow

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.

Force showing titles with splitActionBarWhenNarrow option enabled

It's typical for android apps that if actionbar takes more than 50% of screen width, it moves menu to bottom of screen. Obstacle is that it removes titles too no matter if they would fit or not.
In screenshot below you see comparison of same app run in 480x854 vs 320x480 screen. You can see that it moves menu in smaller screen but removes titles as well despite of that they would fit fine there.
I'm using ActionBarSherlock. According to it's creator The only way to display both would be to use a custom view in the action item that contained both an icon and text.
Can some of you folks give simple example of how to do this? I'm interested only in forcing showing titles, nothing fancy. There is nothing unusual in my app, but if you need sample source codes, I can provide them for you.
You can see that it moves menu in smaller screen but removes titles as well despite of that they would fit fine there.
AFAIK, the bottom portion of the action bar never shows titles.
Can some of you folks give simple example of how to do this?
Add an android:actionView element to your <item> in your <menu> resource, pointing to a layout file that contains whatever you want your fake menu button to be:
<item
android:id="#+id/add"
android:actionLayout="#layout/add"
android:icon="#android:drawable/ic_menu_add"
android:showAsAction="ifRoom"
android:title="#string/add"/>
In your Java code, after inflating your menu resource, you can call getActionView() on the associated MenuItem to get at this inflated layout and configure its widgets (e.g., call setOnClickListener()). In my case, the widget I want to configure is an EditText:
EditText add=
(EditText)menu.findItem(R.id.add).getActionView()
.findViewById(R.id.title);
add.setOnEditorActionListener(this);
(snippets from this sample project)
Personally, I'd either get rid of the split action bar or leave it display as it does by default.

Android App with tabs and menu items

I'm trying to implement an application with a specific view. It needs to have a horizontal bar at the top that contains the app icon, and other buttons and spinners. These items must be static and should appear on every page of the app.
Below that horizontal bar will be a Tabbed component, with the tabs being horizontal at the bottom of the page. I can also implement the desired behavior with the tabs on top of the Tabbed component. Each tab will obviously change the fragment being displayed within the tab's frame.
I am working on an implementation that uses the ActionBar and the menu options. However, I can't get the menu options (my buttons and spinners) to appear above the tabs. And I'm not sure if menu options is the right approach. Any ideas?
Silly me! the answer was right there. I simply had to turn the title bar back on (only with no title) and the menu options would appear right into that title bar.
keep in mind that this feature is heavily dependent on the version of android and model of device that you have.
Older phones have a menu button which will bring up the same menu, as do some modern phones (like the galaxy SIII), so, be sure to test this everywhere so you know what the end-user will actually experience.

Android Action Bar Tabs and Menu Items

I am using a action bar. I have menu items on that. I have set the property on it as
android:showAsAction="ifRoom|withText"
So it's working in Potrait and landscape really well. On one page I have Tabs, it's not recognizing tabs and overwriting the tabs. What I would like to do is, in Potarit just show tabs and all menu in drop down. In Landscape show tabs and as many menu items possible on action bar.
Thanks,
Have a res/menu/options.xml and a res/values-land/options.xml to distinguish the cases. Or, if the rule really is not portrait vs. landscape but a minimum screen width, use res/menu/options.xml and res/menu-wNNNdp/options.xml, where NNN is the minimum width in dp for when you want to use some other approach for your menu.

Categories

Resources