本文介绍了视图底部的弹出菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何始终在锚视图的底部显示弹出菜单.这是我用来显示弹出菜单的代码.
How to show Popup menu always at bottom of the anchor view. This is the code I'm using to display popup menu.
PopupMenu popup = new PopupMenu(activityReference, view, Gravity.NO_GRAVITY);
popup.getMenuInflater()
.inflate(R.menu.popup_menu_event_edit, popup.getMenu());
popup.show();
我尝试将Gravity.NO_GRAVITY更改为Gravity.BOTTOM.但它不起作用.
I have tried changinging the Gravity.NO_GRAVITY to Gravity.BOTTOM. But its not working.
推荐答案
此处button1是定位视图,表示您要在其中显示菜单的地方
here button1 is anchor view means referrence where you want to show your menu
PopupMenu popupMenu = new PopupMenu(context, button1, Gravity.TOP);
popupMenu.getMenuInflater().inflate(R.menu.home_drawer_bottom_nav_menu, popupMenu.getMenu());
popupMenu.show();
这篇关于视图底部的弹出菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!