我有一个 DialogFragment。在点击此对话框 fragment 中的按钮时,我需要在对话框 fragment 中的特定编辑文本上方显示一个弹出窗口。为此,我使用
找到编辑文本的绝对坐标int[] coords = {0,0};
editText.getLocationOnScreen(coords);
并使用
在所需位置显示弹出窗口popup.showAtLocation(popupView, Gravity.NO_GRAVITY, coords[0] + edittext.getWidth(), coords[1]);
但是这样做会在对话框 fragment 后面显示弹出窗口。有什么方法可以让对话框 fragment 上方弹出?
最佳答案
好吧,我发现了我的错误。 popUp.showAtLocation 的第一个参数应该是 getView() 而不是 popUpView。
popup.showAtLocation(getView(), Gravity.NO_GRAVITY, coords[0] + edittext.getWidth(), coords[1]);
这现在在 dialogFragment 上方绘制弹出窗口
关于android - Popup 出现在 DialogFragment 后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25260567/