Android Menu Icon with Title : Title doesn't display - android

Here is my XML
<?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/refresh" android:title="Home"
android:icon="#drawable/menu_home" />
<item android:id="#+id/search" android:title="Search"
android:icon="#drawable/menu_search" />
<item android:id="#+id/help" android:title="Help" android:icon="#drawable/menu_help" />
</menu>
Icon is getting displayed but title doesn't. Please advise.

I'll post this as an answer then...
The size of menu pixes can be too large (such as 72x72). Make sure you use the proper size icons for your current display.

I had the same problem, but my menu icon size was 32x32. And still displayed over the text. So, I played a little with the sizes, and set it to about 47x47 and it finally worked.
So, if this happens, try to play with the image sizes.

Related

Android add buttons to ActionBar

I have a problem, in my app I need to add 2 buttons to the ActionBar, i change the menĂ¹ file in this way
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/navigation_drawer"
android:icon="#drawable/ic_drawer"
android:title="Drawer"
android:showAsAction="ifRoom" />
<item android:id="#+id/info"
android:icon="#drawable/ic_info_outline_white_24dp"
android:title="info"
android:showAsAction="ifRoom" />
</menu>
but my items are in the overflow button without the image , only the text , how can I do to take off from there and make images appear on ActionBar ? it would be possible to put one on the left and one to the right of the name of the app ?
You can use android:showAsAction="always" to make them always show on the ActionBar.

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.

Trying to color tabs on ActionBar

I am adding an actionbar to a test app I'm writing, and I see questions throughout stackoverflow about this, but nothing that has helped me at all. Based off of this guide:
http://android-developers.blogspot.com/2011/04/customizing-action-bar.html
I'm trying to change the select color for tabs that i'm using on my action bar. The default is that faint blue color. Just as a test I did this:
<style name="CustomTab" parent="android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">#000000</item>
</style>
That gives me a solid black tab completely, not the selector part. Can someone help better direct me here? I can't seem to find a good example anywhere.
First you have to define a selector xml file then write this code there and replace your code with this
item name="android:background">#drawable/yourfilename</item>
and the selector xml
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:state_pressed="true"
android:drawable="#drawable/picture_selected" />
<item
android:state_focused="true"
android:drawable="#drawable/picture_selected" />
<item
android:drawable="#drawable/picture_unselected" />
</selector>

Android 3.0: Changing order of icons in the action bar

I am working with the Android 3.0.
I have in the action bar 3 items and one of them is the menu of the application, it also has sub-menu in it.
I want to change the order of the icons so the menu won't be in the right place, I want it to be between the two other items. I tried to change the order in the xml with no success.
Does anyone has an idea how to set the order?
Try setting android:menuCategory and android:orderInCategory for your menu items to set the ordering.
Example:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/launch_search"
android:icon="#android:drawable/ic_menu_search"
android:title="#string/search_programs"
android:menuCategory="container"
android:orderInCategory="2"
android:showAsAction="always" />
<item android:id="#+id/preferences_screen"
android:icon="#android:drawable/ic_menu_preferences"
android:title="#string/preferences" />
<item android:id="#+id/refresh"
android:icon="#drawable/ic_menu_refresh"
android:menuCategory="container"
android:orderInCategory="1"
android:title="#string/refresh_items"
android:showAsAction="ifRoom" />
</menu>
It will have the same effect as declaring launch_search -action as last, but this way you'll have your actions in the right order for 2.x and older devices while being able to control action ordering for 3.x -devices.
The menu will always go to the right, you cannot control its placement.

Categories

Resources