Мне нужно закрыть свое всплывающее окно при нажатии на пустое место, но при прокрутке мне нужно показать всплывающее окно. Теперь мое всплывающее окно скрыто при прокрутке, пожалуйста, помогите мне решить эту проблему. Вот мой код:
private void showPopup(View view, String text) {
if (infoPopup == null) {
LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
View popupView = layoutInflater.inflate(R.layout.popup, null);
TextView tvPopupText = popupView.findViewById(R.id.tv_popup);
tvPopupText.setText(text);
FrameLayout flBackground = popupView.findViewById(R.id.fl_bg);
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.showAsDropDown(view);
infoPopup.setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
dismissInfoPopup();
return true;
}
return false;
}
});
} else {
dismissInfoPopup();
}
}
private void dismissInfoPopup() {
if (infoPopup != null) {
infoPopup.dismiss();
}
infoPopup = null;
}
Теперь всплывающее окно отображается при прокрутке, но когда я нажимаю снаружи, всплывающее окно не скрывается.