我需要在按钮上方直接显示弹出窗口。我的按钮位于滚动视图中,弹出窗口始终显示在按钮下方。这是我的代码:
private void showPopup(View view, String text) {
if (infoPopup == null) {
LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
View popupView = layoutInflater.inflate(R.layout.popup_credit_request_passport, null);
TextView tvPopupText = popupView.findViewById(R.id.tv_popup_text);
tvPopupText.setMovementMethod(new ScrollingMovementMethod());
tvPopupText.setText(text);
FrameLayout flBackground = popupView.findViewById(R.id.fl_background);
flBackground.setBackground(new BubbleDrawable(getContext(), R.color.azure, 16, 16, 8));
infoPopup = new PopupWindow(popupView,
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
infoPopup.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
infoPopup.setOutsideTouchable(true);
infoPopup.showAtLocation(view, Gravity.TOP, (int) view.getX(), (int) view.getY());
} else {
dismissInfoPopup();
}
}
答案 0 :(得分:1)
将重力设为顶部,然后根据需要重置坐标。
ssh ubuntu@POD_IP
mkdir new_file
ls
new_file
reboot
答案 1 :(得分:1)
当您必须显示弹出窗口时,找出按钮在屏幕上的位置,然后将showAtLocation()
方法用作 Prachi ,使用Gravity.TOP
和{屏幕上按钮的{1}} ...