This is my code :
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
LayoutInflater li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
menubuttonClosed = li.inflate(R.layout.menu_button, null);
menubutton = (ImageButton) menubuttonClosed.findViewById(R.id.menubutton);
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FILL_PARENT,
WindowManager.LayoutParams.FILL_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.x = 0;
params.y = 0;
menubutton.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
return true;
case MotionEvent.ACTION_UP:
Log.i("midoka", "click");
return true;
case MotionEvent.ACTION_MOVE:
return true;
}
return false;
}
});
windowManager.addView(menubuttonClosed, params);
I wanted to add a layout with a button to the windowmanager, the button should respond to events (click, touch..), but the layout must keep sending touch events to the window behind, is there a way to do that ?