Android: SurfaceView and Z-Level Question

Posted by JimBadger on Stack Overflow See other posts from Stack Overflow or by JimBadger
Published on 2011-01-12T13:50:14Z Indexed on 2011/01/12 13:54 UTC
Read the original article Hit count: 219

I have a FrameLayout containint first a SurfaceView, and second a RelativeLayout which in turn contians various Buttons and TextViews.

Upon the canvas of the SurfaceView I am drawing numerous Bitmaps, and, via Touch and Motion Events am allowing the user to drag them around.

These Bitmaps, when dragged around pass underneath the Buttons etc that are inside the RelativeLayout.

Now, it's my (possibly mistaken) understanding that the "Z-level" of the SurfaceView, or whatever it has that passes for it, is entirely unrelated to the actual Z-level of the rest of the Layout. Is this the case? If so, how may I get around it, so that dragged Bitmaps are drawn ontop of other Views? Or what other way can I implement a full-screen canvas and yet not have my buttons etc act like the controls of an overlay.

I guess what I actually need is an underlay, where touch events can still be picked up by the Buttons etc underneath. But I don't know how to achieve this, as, when redrawing my Canvas, I have to also redraw the background.

Can I swap the order of the RelativeLayout and the SurfaceView inside the FrameLayout, and then make the background of the Canvas transparent? If so how? Will touch events still "fall through" to the buttons underneath?

Thanks for bearing with me, I know I'm a bit of a waffler.

© Stack Overflow or respective owner

Related posts about android

Related posts about canvas