leondzn
leondzn

Reputation: 107

How to make overlay receive touch events without consuming the touch for the other apps?

I'm currently trying to make a utility overlay similar to Facebook Messenger chatheads in which you can move the view around the screen. When you click the view, it expands into a more complex layout. However, the problem is if I set the LayoutParams' flag to WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, the apps behind receive the touch events while my overlay doesn't receive any touch events at all. But if I remove that flag, the overlay receives the touches but it blocks the touch. Meaning I can't even open the app drawer since the touches are being blocked.

I am using a fullscreen transparent Activity as background so I can move my overlay "widget" around it.

Is there any way I can make it so that it doesn't block touch events. Even if I don't set it to fullscreen, as long as I don't have the FLAG_NOT_TOUCHABLE flag, my overlay completely blocks all screen touches.

Upvotes: 0

Views: 3031

Answers (1)

Kundan Singh
Kundan Singh

Reputation: 91

Please Remove this flag

WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE 

with this flag

WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE

see this link https://medium.com/@kevalpatel2106/create-chat-heads-like-facebook-messenger-32f7f1a62064

Upvotes: 2

Related Questions