When I click the space outside the PopupWindow
, the window is dismissed. However, if I want to scroll a ListView
outside the window, the scroll event is first recognized as a click event, and get intercepted by the window, so the window get dismissed, while the scroll is not executed.
How can I scroll the ListView
at the same time the window get dismissed, so that i don't need to scroll it again.
Try this set of properties:
window.setTouchable(true);
window.setOutsideTouchable(true);
window.setFocusable(false);
in this case your popup won't be dismissed when you click outside of its frame, but you can add a listener to catch outside touches and dismiss the popup:
window.setTouchInterceptor(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
window.dismiss();
return true;
}
return false;
}
});