Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Popup appears behind DialogFragment

I have a DialogFragment. On tapping a button in this Dialog fragment I need to display a pop up window above a particular edittext in the dialog fragment. To do this I find the absolute co-ordinates of the edittext using

int[] coords = {0,0};
editText.getLocationOnScreen(coords);

and display the popup at the required location using

popup.showAtLocation(popupView, Gravity.NO_GRAVITY, coords[0] + edittext.getWidth(), coords[1]);

But doing this displays the pop up window behind the dialog fragment. Is there any way to get the pop up above the dialog fragment?

like image 392
DevAndroid Avatar asked Sep 17 '25 06:09

DevAndroid


1 Answers

Okay, I figured out my mistake. The first parameter for popUp.showAtLocation should be getView() instead of popUpView.

popup.showAtLocation(getView(), Gravity.NO_GRAVITY, coords[0] + edittext.getWidth(), coords[1]);

This now draws the popup above the dialogFragment

like image 84
DevAndroid Avatar answered Sep 18 '25 19:09

DevAndroid