I am trying to implement the action bar functionality of the flipkart app..
For this I have successfully created a custom Action Bar but I am facing problems in showing the menu as drop down on overflow icon click.
If I try Android Option Menu on button click then on I am getting the menu without icons (4.2.2) at the bottom center of my screen. Using a custom dialog or alert dialog fades the background and they also appear on the center of the screen.
What should I do to get the functionality similar as shown in the image above?
The only way that I could get the icons to show was by calling setForceIcons before inflating the menu.
You can easily use
ListPopupWindow
and any convenient for youadapter
:getWidestView
snippet you can find here: https://stackoverflow.com/a/13959716/4890659A simple way I have is put the overflow menu by you and add all those menu as sub menu in that, by that way you achieve this view. Also this overflow menu display as always in your ActionBar
Try this way,hope this will help you to solve your problem.
Please follow link instruction to shown popup menu item with image and you can use showAtLocation() to shown popup as desired location.
Check : PopupMenu with icons
If you're looking for a more Material popup menu and are not afraid of Kotlin you could try: https://github.com/zawadz88/MaterialPopupMenu - there's no need to declare menus in XML and you could handle clicks more easily.