我有一个总是显示在屏幕上(在其他应用程序之上)的视图,我想接收触摸事件并将它们传递下去。
来自运行中的 Service
的代码:
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT);
v.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Toast.makeText(getApplicationContext(), "view touched", Toast.LENGTH_SHORT).show();
return false;
}
});
WindowManager localWindowManager = (WindowManager)getSystemService("window");
localWindowManager.addView(v, localLayoutParams);
目前我无法获取触摸屏幕的输入。
onTouch
дәӢ件...еҪ“жҲ‘дҪҝз”ЁFLAG_WATCH_OUTSIDE_TOUCH
ж Үеҝ—ж—¶пјҢжҲ‘иғҪеӨҹдёҺе…¶д»–еә”з”ЁзЁӢеәҸиҝӣиЎҢдәӨдә’гҖӮ - RCB