views:

43

answers:

2

Is it possible to have multiple separate Canvas layers, which I can merge to one? Similar to what I'd do in photoshop?


Update:

Some explanation why I'd like to have something like that: Layer1 might hold something that has been created by a complex and CPU expensive algorithm while the other layer, Layer2, is something that just goes on top of that, but changes regularly, e.g. when a user touches the interface. For that I don't want to go through the whole process of drawing the underlaying Layer1 again, but just make the changes to Layer2 and then "merge" them.

+1  A: 

Well, you can have something like a FrameLayout in which you override onDraw() and have server sub-elements in which you also override onDraw().

This might give you the effect you want.

Miguel Morales
A: 

Out of curiosity, what can multiple canvas layers accomplish that organizing your draw order can't?

`Layer1` might hold something that has been created by a complex and CPU expensive algorithm while the other layer, `Layer2`, is something that just goes on top of that, but changes regularly, e.g. when a user touches the interface. For that I don't want to go through the whole process of drawing the underlaying `Layer1` again, but just make the changes to `Layer2` and then "merge" them.
znq
I still don't understand why you'd need to merge the two layers. A FrameLayout with two views, the first one with your expensive graphic, the second above it, with your inexpensive UI. The second would have a transparent background so you can see through to the first. As for your question: I don't know of a built in method. Maybe you should describe more detailed what you want to do and why. Perhaps someone has a completely different solution to your base problem than the way you're trying to go.
Matthias Schippling
Yepp, the FrameLayout would work. I didn't even think about that, because I was already thinking and programming in the 2D low level graphics, that I was looking for a solution there. Anyway, the solution I finally came up with is using two offscreen bitmaps, one for the expensive graphics, and the other one for the frequent small changes. And then I just draw them on the canvas one after the other.
znq