How to launch a transparent activity so that background activity is able to take events

后端 未结 2 343
不思量自难忘°
不思量自难忘° 2021-01-12 17:04

Is it possible in android that one transparent activity is on the top and a background activity is able to handle the events?

If yes then please refer the below imag

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 17:50

    I was able to make this work with the following code in my transparent foreground activity

    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            // Pass touch events to the background activity
            getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                            | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
    ...
            setContentView(R.layout.main);
    }
    

提交回复
热议问题