I noticed some context menus in various tutorials on the web look different than mine, i.e. there a title with an arrow in a circle at the top. Mine is just a square box with items. Is this just a newer version of the context menu, or is there a way to style the menu?
I'd like to center the items, set a backcolor, etc.
ContextMenu has several methods like setHeaderTitle()(for adding a title, but you have setHeaderView() for more complex stuff) so you can customize the ContextMenu in the method onCreateContextMenu().
Related
I'm trying to do something like the mockup I drew below. I have menu items but on each I want one image view and one text view. All I'm seeing is title and icon attributes in the menu items which don't do the job.
If you want to use the standard Android widgets (Menu, MenuItem, etc), then no, this is not possible.
However, you could create your own floating view that looked just like a standard Android menu, and then do whatever you want.
I want to make my app in Material Design, but one thing I noticed was that the ContextMenus are themed in Holo, as seen here: .
Is there a way to make the context menu Material Themed?
Maybe this post helps:
Styling the popup menu in Android 5.0
They try to do exactly the opposite there. Note that using the ActionBar and using the right application/activity theme should do the trick.
This however is for the ActionBar context menu. I think the longpress ListView context menu is being phased out. It might be possible to make a custom theme for it though:
Android: Theme ContextMenu item selection
If I don't use show as action=always when creating a menu will it create a menu on the bottom like the old school android phones. I'm trying to create something that has like the facebook mobile tabs on the bottom, and has them for every screen. Or should I actually just make tabs for every screen?
You may be interested in a "split action bar". That way your items could appear at the bottom. showAsAction controls how/if the item appear in the Action Bar.
More information here: http://developer.android.com/guide/topics/ui/actionbar.html#SplitBar
If that doesn't look of interest then yes.. you should use tabs (or a view of some sort) at the bottom to render your "menu items".
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).
I feel stupid for asking: What are the drop menus on honeycomb apps called? I'd like to use them in my app but i don't even know where to start.
An Example from Google Music, notice the triangle in the corner:
Here it is opened:
I found the Menu, which appears in the top right. I don't think they are context menus which you usually see associated with long holding touches.
(I realize these images are from the website, but they are all over honeycomb apps too)
The action bar will display your Activity's options menu in the top right automatically, but PopupMenu might be what you're looking for. It lets you generate a simple popup menu anchored to any View in your UI. Inflate a menu resource into the Menu object returned by getMenu, set a listener to respond to the user making a choice from the menu and call the show method.