public class PopupWindowUtil { public static boolean isKeyDown(PopupWindow popupWindow) { View content = popupWindow.getContentView(); if (content == null) return false; View backgroundView = (View) content.getParent(); if (backgroundView == null) return false; View view = (View) backgroundView.getParent(); KeyEvent.DispatcherState state = view.getKeyDispatcherState(); boolean isKeyDown = state.isTracking(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK)); if (isKeyDown) { state.reset(); } return isKeyDown; } }
PopWindow 返回键关闭拦截
最新推荐文章于 2019-02-25 22:59:16 发布