I'm struggling to understand the process of drawing to SurfaceView
and therefore the whole Surface
/Canvas
/Bitmap
system, which is used in Android.
I've read all articles and API documentation pages, which I was able to find on android-developers site, a few tutorials of android graphics, LunarLander source code and this question.
Please tell me, which of these statements are true, which are not, and why.
Canvas
has its own Bitmap
attached to it. Surface
has its own Canvas
attached to it.
- All
View
's of window share the same Surface
and thus share the same Canvas
.
SurfaceView
is subclass of View
, which, unlike other View
's subclasses and View
itself, has its own Surface
to draw in.
There is also one additional question:
- Why is there a need for a
Surface
class, if there is already a Canvas
for high-level operations with bitmap. Give an example of a situation where Canvas
is non-suitable for doing work which Surface
can do.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…