How can I interact with elements behind a translucent Android app?

后端 未结 3 952
星月不相逢
星月不相逢 2020-12-03 00:22

I have found how to create a translucent background for my android app, but so far I haven\'t found how to interact with what\'s behind it (the home screen for example).

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 00:34

    I got the answer. Adding line getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); in onCreate in second top activity(which is transparent did the trick).

    Above solution has a problem. After using above whole window passes the touch to background. So if you want full control then better extend a layout e.g. Framelayout and override 'onTouchEvent' and get the touch location using event.getX() and event.getY() methods and return false where you want to pass the touch event. It will be passed to parent view.

提交回复
热议问题