将popupmenu锚定到actionbar的溢出视图

时间:2013-06-08 08:16:13

标签: android android-actionbar popupmenu

我在操作栏中有一个menuItem,单击时会显示一个popupMenu。

对于较小的屏幕尺寸,menuItem会溢出。 当发生这种情况时,我喜欢将popupMenu锚定到溢出图标。 如何获取操作栏溢出按钮的视图?

 private void showPopupDisplayLocalDescription() {
     View anchor = findViewById(R.id.menu_display_local_description);

     if (anchor == null) { //menuItem has overflowed.

          anchor = ?? <how do i get the view of the overflow icon?
     } 
     popup_localDescription = new PopupMenu(this, anchor);

     MenuInflater inflater = ... //the rest of the codes 

     popup_localDescription.show();
}

0 个答案:

没有答案