How to set only image as menu item in android - android

I have created options menu it has some attributes like android:I'd, android : title,android:icon etc how can I set a image as android option menu and also I want title of the item below the icon not beside the icon

You cannot do this easily and you should not. What you explain sounds more like Tabs to me, which you could use instead. With these you'll get text below the icon out of the box.

Related

How to make the overflow button (the three dots) open settings right away?

I do not want to show a menu for only Settings and About, that's why i want the overflow button to open (immediately when clicked) a unified Settings-About page, the same way Instagram does.
At first i thought i might just do a menu with one action that is set to always Shown and has the overflow button icon (the three dots). But there are a lot of icons for different themes and i also think this wouldn't be correct for devices with a menu button.
Follow this:
Go to style, change your theme DarkActionBar to noActionBar.
Add the android design support to your gradle.
Add toolbar to your xml
Add Imageview or imageviewbutton inside your toolbar
Find the three dot image in drawable using image asset
Add your three dot drawable as src of your imageview.
Set oncClick then intent.

android overflow menu item is unable to display both icon and title

I am trying to set image in overflow menu items like as in flipkart.But I am unable to set image.Can anybody provide me code snippet for doing this
If you are trying on Android 3.0+, it won't show icons in the menu items. Google has removed them in order to make the menu look similar on different apps. See icon in menu not showing in android and on Android Developers blog.
It is not possible to add icons in overflow menu item as per googles new change, If u still want, try this.
for device with overflow hardware button:
override hardware button click and show a transparent fragment with list view as like over flow menu in samsung devices(S3, s4) with icon.
for devices without hardware button:
use sub menu to look as menu. google still supports icon in sub menu.
That's how it's supposed to work.
If the icon shows in the action bar, it will only show the icon (with an optional title by using android:showAsAction="always|withText" or android:showAsAction="ifRoom|withText").
If the icon does not show in the action bar, it will only show in the overflow menu as text. Note that there is no "withIcon" enum value for the android:showAsAction attribute.

Android Actionbar PopupMenu with Custom Item Layouts

I am working on an Android application where I have to design a menu which will populate from the action bar, like this:
I have tried my best but was not able to produce it using the Android controls.
The solutions I have tried are:
With Actionbar, add a menu item with a group with selectable="all", that produces the layout I need but when I click a checkbox for selecting it, the whole menu hides and selection is not done, moreover the menu icon in actionbar does not have the bottom right white arrow.
Tried creating a custom ActionProvider and added the menu items using class's OnPrepareSubMenu method but had the same issue.
I just need a push in the right direction and I can do the rest, suggestions are more than welcome.
Thank you :)
Use popupWindow.
In that you can make any custom layout and set it as content of your popupwindow and also you can specify an ANCHOR in your case it would be
R.id.your_menu_item
set a listener and listen the changes.

Android Sub Menu Changes Background Color

I have an android application that I want to add a sub menu for. The background of the application is the default which is black. All of the text on the app is white which I also think is the default. So I added in the sub menu but when I click on the sub menu the background turns to white but the text doesn't turn to black.
Any idea why the default sub menu behavior isn't working correctly? I'm hoping not to have to create styles and all that and the solution will be fairly simple.
Figured this out. This was due to me using titleCondensed instead of just using title. For some reason on sub menus it needs to use title but on the regular menu it works fine. Programming mistake by me.

Android menu item background

I want to change the menu item background beacuse I use black icons, but on some phones the default color of background is black or other dark color. I tried this solution and it's worked but there was a little problen with it:
I have ten items and that's why I have a "More" item to show other options, but if I choose the More item (which is got the custom background) and after that I press back button, the item will be in the default state, default colors. What is the solution? Thanks!
The style attribute for the menu background is android:panelFullBackground. It's not hackish like the other solution, so it's not as buggy.
Despite what the documentation says, it needs to be a resource (e.g. #android:color/black or #drawable/my_drawable), it will crash if you use a color value directly.
try to use android own menu icon like as setIcon(android.R.drawable.ic_menu_search)

Categories

Resources