Thanks for the indepth reply! Maybe you as Android Framework Developer can give a recommendation on how I best implement the following: I have camera preview and want to overlay my own item over this that change very quickly (about every 200ms).
The camera preview uses a SurfaceView as in the samples. As first approach I used a normal View as the overlay part and called postInvalidate from another thread very often to redraw the View. This caused heavy CPU load (90%) of my application. Now, I managed to use two SurfaceViews and making one transparent. This also works and the CPU load is about 30% now. However: is this the best way to implement such functionality? Thanks! Chris On Jul 27, 8:07 pm, Dianne Hackborn <[email protected]> wrote: > Sorry, you can't do this -- because surface views are very special and not > really views (the surface is a separate window Z-ordered with your own), > their Z-ordering does not match your views. A surface view is a big, heavy > object; you are not intended to treat SurfaceView like a regular view in > this way. > > As far as transparency, the surface is transparent if you make its pixel > format transparent. It's your surface, you can do with it what you want. > The default is to be the same pixel format as the screen, since that is the > most efficient and it is very rare for someone to want a transparent surface > view. > > The way you really are intended to do this is to own the surface, and draw > all your compositing in there. So you would just have one surface view that > you are updating in the places where either the background or overlay is > changing. To be honest, I think you are going to get better performance if > you do it this way anyway, especially if you use OpenGL. > > For simple overlays, one thing that is reasonable to do is to stick the > SurfaceView in a frame layout, Z-ordering it below other -regular- views > that contain the overlay. There is an example in ApiDemos of this. > > > > On Mon, Jul 27, 2009 at 7:34 AM, Chris <[email protected]> wrote: > > > Hi, > > > I have two SurfaceViews in one FrameLayout. So they are stacked upon > > another. What I want to achieve is to use the lower SurfaceView as > > kind of background that is changing heavily, and the upper SurfaceView > > as annotation overlay. So the upper SurfaceView has a (small) number > > of quickly changing elements that I will draw. > > > Somehow, I can always only see one of the SurfaceViews, depending on > > which one is top. I thought that SurfaceViews are always transparent, > > but it seems I am missing something here. > > > Any thoughts on why I can't overlay two SurfaceViews? > > > Thanks, > > Chris > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

