I just like to implement somethings same as popup menu in the Gmail app, anchored to the overflow button at the top-right. for that I used the same code as google tutorial f
After trying out each approach that I have found, I would think putting an anchoring view might still be an easier and simpler way, especially when you are using a more flexible layout, e.g. ConstraintLayout.
Just put an invisible view to where you want the popup menu to anchor:
Then use it as the anchoring view instead:
mPopupMenu = new PopupMenu(getActivity(), mPopupMenuAnchor);
Boom, it is done.