@SuppressWarnings("PMD.NPathComplexity") // split up would not help readability
    public void show() {
        final ViewGroup root = activity.getWindow().getDecorView().findViewById(android.R.id.content);

        final View anchorView;
        if (view != null) {
            anchorView = view;
        } else {
            anchorView = new View(context);
            anchorView.setLayoutParams(new ViewGroup.LayoutParams(0, padding * 2));
            anchorView.setBackgroundColor(Color.TRANSPARENT);

            root.addView(anchorView);

            anchorView.setX(point.x);
            anchorView.setY(point.y - padding);
        }


        final PopupMenu popupMenu = new PopupMenu(context, anchorView);

        if (menuRes != 0) {
            popupMenu.getMenuInflater().inflate(menuRes, popupMenu.getMenu());
        }
        if (onCreateListener != null) {
            onCreateListener.onCreatePopupMenu(popupMenu.getMenu());
        }

        for (Triple<Integer, CharSequence, Drawable> item : additionalMenuItems) {
            final MenuItem menuItem = popupMenu.getMenu().add(Menu.NONE, item.getLeft(), Menu.NONE, item.getMiddle());
            if (item.getRight() != null) {
                menuItem.setIcon(item.getRight());
            }
        }

        popupMenu.setOnDismissListener(menu -> {
            if (view == null) {
                root.removeView(anchorView);
            }
            if (onDismissListener != null) {
                onDismissListener.onDismiss(menu);
            }
        });
        popupMenu.setOnMenuItemClickListener(item -> {
            final OnItemClickListener itemClickListener = itemListeners.get(item.getItemId());
            if (itemClickListener != null) {
                itemClickListener.handleItemClick(item);
            }
            if (onItemClickListener != null) {
                return onItemClickListener.onMenuItemClick(item);
            }
            return true;
        });

        popupMenu.setForceShowIcon(true);

        popupMenu.show();
    }
Will only have an effect if no view is set as anchor. Both values are in px.
main/src/main/java/cgeo/geocaching/ui/dialog/SimplePopupMenu.java