TYPE_PHONE overlay view doesn't allow child Gr

2019-05-31 15:49发布

问题:

My applications draws an overlay which has a GridView as it's child. All the clicks are being captured by the overlay veiw's onTouch event and nothing is passed to the GridView's onItemClick event. The code which creates it is:

LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
TaskBarView = inflater.inflate(R.layout.view_overlay, null);
TaskBarViewParams = new WindowManager.LayoutParams(TaskBarInactiveWidth, TaskBarHeight,
            LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
            WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            PixelFormat.TRANSLUCENT);
TaskBarViewParams.gravity = Gravity.LEFT | Gravity.TOP;
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
windowManager.addView(TaskBarView, TaskBarViewParams);

Note: This problem only comes into picture on API levels 16 and up. The GridView captures it's onItemClick and the overlay captures it's onTouch properly as it should below API level 16.

Am I missing a flag or something?