Android Sub-Menu Items Have Extra White Space To Right of Icon - android

I have an Android sub-menu, declared with this code:
<item
android:icon="#drawable/ic_menu_share"
android:showAsAction="ifRoom"
android:title="Share">
<menu>
<item
android:id="#+id/menuSortNewest"
android:icon="#drawable/ic_menu_share"/>
<item
android:id="#+id/menuSortRating"
android:icon="#drawable/ic_menu_share"/>
</menu>
</item>
The problem is that each item in the menu is an icon with a bunch of extra white space to the right of the icon. I just want the icon with no white space beside it. How do I achieve that?
Here is a screenshot of the application:

OP, As per the discussion in the comments, it's likely you'll need to create your own PopUpMenu to get the functionality you desire, please see:
http://stackoverflow.com/a/21329225/1067946
For info on doing it.

Related

Android Action Bar actions not showing all options, or in middle of UI, and other problems

I cannot get my action bar to work right at all. There's way too many crazy examples to run through, but I have encountered things like the action bar overflow bottom showing up halfway down the UI in 4.0.3 (I'm using android:uiOptions="splitActionBarWhenNarrow"), to clicking item A yet item B showing as the selecting item in OnOptionsItemSelected(MenuItem), or not showing them all.
Not trying to do anything crazy. I just want a refresh icon, info icon, share icon to show up and then 2 extra options to show up from clicking the dotted overflow icon. But I cannot get it to work consistently. I need to support 4.0+.
Here's what I have right now. I have slaughtered the menu xml while pulling my hair out, but maybe someone can shed some light on what I must be doing horribly wrong?
This current xml causes the bottom split action bar to sit right in the middle for the 4.0.3 AVD:
<item android:id="#+id/action_refresh"
android:icon="#drawable/ic_action_refresh"
android:title="#string/action_refresh"
android:showAsAction="always" />
<item android:id="#+id/action_info"
android:icon="#drawable/ic_action_about"
android:title="#string/action_info"
android:showAsAction="always" />
<item
android:id="#+id/menu_item_share"
android:showAsAction="ifRoom"
android:title="#string/action_share"
android:actionProviderClass="android.widget.ShareActionProvider" />
<item
android:id="#+id/action_category"
android:showAsAction="never"
android:title="#string/action_category" />
<item
android:id="#+id/action_about"
android:showAsAction="never"
android:title="#string/action_about"/>
Seems like the share action provider was cause of most the issues. Just using an icon with click handler that builds a share Intent instead.
Similar issue:

how to start placement of action buttons from the left in action bar

I am new to android development. Hence, I'm still in the getting-the-hang-of-it mode. I have started off my app by creating an xml file in the res/menu folder, the code for which is shown below. I need help with is placing the first (add) button in the left hand corner, where the title bar is supposed to be located, followed by the remove button in the centre, and finally the overflow menu in the last third. These three entities should be evenly spaced out. Additionally, I have managed to get rid of the app name and icon from the left hand corner.
Any help will be much appreciated.
Thanks in advance
<?xml version="1.0" encoding="utf-8"?>
<item android:id="#+id/setting"
android:title="#string/action_settings"
android:orderInCategory="100"
android:showAsAction="never" />
<item android:id="#+id/add_contact"
android:title="#string/action_add"
android:orderInCategory="1"
android:showAsAction="ifRoom" />
<item android:id="#+id/remove_contact"
android:title="#string/action_remove"
android:orderInCategory="2"
android:showAsAction="ifRoom" />
This is what I want it to look like. It is a screen shot of the Nexus 4 contacts manager. However, I want buttons not tabs:
http://i.imgur.com/iDwUCJl.png
Current output: http://i.imgur.com/sQU3Jjq.png

android menu item doesn't show an image

I have this menu layout
<item
android:id="#+id/refresh"
android:icon="#drawable/refresh"
android:title="#string/refresh"/>
<item
android:icon="#drawable/sort_neutral"
android:title="Sort By Date">
<menu>
<item
android:id="#+id/sortNewToOld"
android:icon="#drawable/sort_up"
android:title="Newest To Oldest"/>
<item
android:id="#+id/sortOldToNew"
android:icon="#drawable/sort_down"
android:title="Oldest To Newest"/>
</menu>
</item>
the items "#+id/refresh" and "#drawable/sort_neutral" are shown correctly, but the two icons inside the "android:title="Sort By Date" are not shown, I just can see the title of them. any help would be appreciated.
note
I am using real mobile song ericsson 2.3.1
Your icon are probably too large for the menu. Make sure you are using a correct icon size.

Getting the right icons for Action Bar (ActionBarSherlock) and Options Menu with Android Gingerbread

How do you manage Icons with ABS and Gingerbread? As you can see from the Screenshots, I have a menu item "Help", that sits in the action bar, when there's room for it. (when nothing is selected). The icon looks good so far. But when it moves into the options menu, I probably should use another icon for better visibility :)
How do you normally do that? Any ideas? This is my menu xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/new_button"
android:showAsAction="always"
android:title="new"
android:icon="#drawable/content_new_calendar"/>
<item
android:id="#+id/share_button"
android:visible="false"
android:showAsAction="ifRoom"
android:title="share"
android:icon="#drawable/social_share"/>
<item
android:id="#+id/help_button"
android:showAsAction="ifRoom"
android:title="help"
android:icon="#drawable/action_help"/>
</menu>
I know how to create different menus for various api levels, etc. But here, the same phone is showing the icon in the action bar and in the options menu. The simplest solution is to set android:showAsAction="never", but from user reviews I learned, that the App is difficult to understand (especially the Widget-Part), so I would love to have the help menu visible. Any ideas?
P.S. I know that the App is ugly and unfinished. It's work in progress and will be polished :)
Try using the force overflow option like so:
<item name="absForceOverflow">true</item>

How to get options from the options menu into title bar ActionBar Sherlock android

I am trying to get my options to show up in the Title Bar. I'm using ActionBarSherlock and I can figure out how to remove the title in the title bar, but would like to replace the text with 2 options from my options menu.
I'm using this code, EmpubLite as an example for my application, but I can't figure out how Mark (the commonsware guy) got the icons from his options menu in the title bar. My options show up at the bottom in the action bar and this is taking up unnecessary room on the screen. I've been looking through examples here, but can't seem to find out exactly how to get options in the title bar. I'm hoping Mark (or someone) can explain.
would like to replace the text with 2 options from my options menu
Um, unless that happens automatically by removing the title, I suspect that's not possible.
but I can't figure out how Mark (the commonsware guy) got the icons from his options menu in the title bar
Well, you see, that's covered in this delightful little book... :-)
More seriously, android:showAsAction controls whether items should be in the overflow area (never), should be in the action bar (ifRoom), or really really should be in the action bar (always). That being said, always is a hint, not a demand, and the OS may still put your action bar items in the overflow on smaller screen sizes.
You did not state which of the EmPubLite series you are experimenting with. Early on, the items are all set to never:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/help"
android:icon="#android:drawable/ic_menu_help"
android:showAsAction="never"
android:title="#string/help"/>
<item
android:id="#+id/about"
android:icon="#android:drawable/ic_menu_info_details"
android:showAsAction="never"
android:title="#string/about">
</item>
</menu>
By the end of the series, we have some that ideally go into the action bar:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/notes"
android:icon="#android:drawable/ic_menu_edit"
android:showAsAction="ifRoom|withText"
android:title="#string/notes">
</item>
<item
android:id="#+id/update"
android:icon="#android:drawable/ic_menu_save"
android:showAsAction="ifRoom|withText"
android:title="#string/download_update">
</item>
<item
android:id="#+id/settings"
android:icon="#android:drawable/ic_menu_preferences"
android:showAsAction="never"
android:title="#string/settings">
</item>
<item
android:id="#+id/help"
android:icon="#android:drawable/ic_menu_help"
android:showAsAction="never"
android:title="#string/help">
</item>
<item
android:id="#+id/about"
android:icon="#android:drawable/ic_menu_info_details"
android:showAsAction="never"
android:title="#string/about">
</item>
</menu>
My options show up at the bottom in the action bar and this is taking up unnecessary room on the screen.
You have android:uiOptions="splitActionBarWhenNarrow" set in your manifest somewhere, then.

Categories

Resources