我已经成功创建了一个覆盖活动,它允许将触摸输入发送到它后面的窗口。一切正常,但是,它显着减慢了设备的速度,我的猜测是因为它创建了如此大的覆盖?我真的不需要覆盖屏幕的整个区域,从技术上讲,它可以大到 2 x 2 像素。
这是我的代码
inflater = LayoutInflater.from(getApplicationContext());
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_FULLSCREEN, PixelFormat.TRANSLUCENT);
params.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
params.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
params.flags |= WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
//params.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
WindowManager wm = (WindowManager) getApplicationContext().getSystemService(WINDOW_SERVICE);
ViewGroup mTopView = (ViewGroup)inflater.inflate(R.layout.dummy, null);
getWindow().setAttributes(params);
mTopView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
wm.addView(mTopView, params);
这正是我想要它做的,但就像我说的,它明显减慢了设备的速度。如何创建叠加层但仍保留系统性能?