How to realize this custom popup menu with Materia

2019-02-04 07:31发布

I want to realize a custom popup menu like Twitter in Android for example with item and picture but I don't know what's the component used for that.

In Material Design website, google present this solution. So I think, there is a native solution to achieve this.

enter image description here

I tried with Popup menu, but I can't find how to customize the layout of this view like that.

7条回答
手持菜刀,她持情操
2楼-- · 2019-02-04 08:12

Easier solution. Add this just before you .show() method.

try {
  Field mFieldPopup=popupMenu.getClass().getDeclaredField("mPopup");
  mFieldPopup.setAccessible(true);
  MenuPopupHelper mPopup = (MenuPopupHelper) mFieldPopup.get(popupMenu);
  mPopup.setForceShowIcon(true);
} catch (Exception e) {}
查看更多
登录 后发表回答