After much struggling, I have determined that a SurfaceView
won't do what I want it to do, namely, be above some UI elements and below others. I've also discovered that drawing all the UI elements on to the SurfaceView
is actually significantly slower than the multi-layered hierarchy I was trying to replace. Therefore, I am trying to code my own animated View
using onDraw()
.
The simplest method I can think of for this is roughly as follows:
invalidate()
onDraw()
I already have a nextFrame()
function from my SurfaceView
which does steps 1 and 2, and the draw function is actually trivial—a single path. I could make nextFrame()
call invalidate()
and I could make onDraw()
call nextFrame()
to signal that the drawing has completed and we are ready for the next frame. Unfortunately, I can imagine this causing problems.
Does invalidate()
directly call onDraw()
? Will I need to implement a calling thread as in SurfaceView
?
No, it will not cause a stack overflow.