I'm currently trying to implement a popup menu that will appear after I clicked on an icon inside a fragment [The image is a part of the fragment in terms of layout]. I am able to make the popup menu show up. However, there is a problem that the menu shows on top of the Bottom Navigation instead of displaying below the icon.
https://i.stack.imgur.com/BoYKF.png
mImageViewAddPerson = rootView.findViewById(R.id.message_img_addFriend);
initRecycler(rootView);
mImageViewAddPerson.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PopupMenu popupMenu = new PopupMenu(getContext(), rootView);
popupMenu.inflate(R.menu.add_person_menu);
popupMenu.show();
}
})
Any suggestion on how to fix it?
Edit
I tried to implement the icon in the main Activity/Intent (This intent includes all the fragments) in order to show popup menu under the icon, but I don't know whether or not it's a right way to implement it.