0

I have an Android activity that is largely transparent, much like a toast. However it is different from a toast in that while shown, it can be interacted with, e.g. it offers a button you can press.

What I would like to do is catch & consume touchscreen input within the display area of my UI, and pass everything else to whatever activity happens to be beneath (which may not be my app).

It's obviously possible to have one or the other, but is this selective model possible?

This is common in other UI languages but I suspect that this, in particular the selective accept of an event to avoid further processing, is not permitted by the model.

So far I've had a look at WindowManager.LayoutParams flags & types, but I can't even get into a state where all input is sent to underlying activities (as per a toast).

Any thoughts would be appreciated.

Rob Pridham
  • 4,086
  • 1
  • 22
  • 32

1 Answers1

0

It transpires that this is possible, and the answer is broadly as found in this SO question.

One key point is that this is a service, and the same approach does not work from an activity - because it is inherently the underlying activity even when transparent (duh). The boolean result returned by the onTouch(...) method allows you to selectively consume handling of the event.

I haven't looked at what implications this has for view construction yet, because this is a slow burning issue for me.

Community
  • 1
  • 1
Rob Pridham
  • 4,086
  • 1
  • 22
  • 32