Search code examples
androiduser-interfacetransparency

How to listen for UI updates that occur behind a transparent view


I am currently trying to find out when a UI update occurs behind a view that is transparent.

This transparent view is the one that I would like to "register" those events.

I have already tried to extend any view and intercept the onDraw method, however it never triggers when anything updates behind the view.

I have also tried ViewTreeObserver addOnPreDrawListener, addOnDrawListener and addOnGlobalLayoutListener, they also never trigger when anything updates behind the view.

I have also tried doing the same as above but attached to the rootView, same result.

Is there a way to achieve this and if yes then how?

EDIT: Context requested in comments

I want to create a blurred image of what is behind the transparent view and I want it to be up to date, that means if the background updates the blurred image updates as well. I don't want to learn how to blur, I can already do that, that's not what this question is about.


Solution

  • It appears that this is not possible because the UI within the same window is tied to itself, meaning that any time a UI of the current window is updated the View I wanted to change would also trigger a UI update resulting in a recursive loop.

    Additionally if a view is not visible any changes to it do not trigger any UI flags, that means views that are changing behind any static view will not trigger any event that could work for what I wanted.