1

我在操作栏中有一个 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();
}
4

0 回答 0