This is a quick explanation to give context to my other post in SurfaceView and SurfaceHolder, which is really what I wanted to talk about :)
The fundamental way
to set what we present in our Activity, in its surface, on what you
see, is to call the Activity method setContentView(something) on the
onCreate method of the activity. The
"something" can change depending of the complexity/capabilities of what
we want to do:
For
simple stuff on the background, like buttons, horizontal or vertical
lines, etc... the "something" will be a reference to a layout, like:
R.layout.activity_main, which is created in xml. This is the typical way
explained in many "hello world" tutorials to setup your Activity, more
than to really "draw".
For more advanced static views, the "something" is an object from a View class. We can then do calls to the View methods (like setbackground...) or in
the onDraw method of the object use calls of the type
canvas.drawsomething... The View class has callback methods for a bunch
of things. onDraw is one of them, but others take care of window
resizing (onSizeChanged), finger interactions with the window (onTouch), etc...
See the post here by Janusz or MuhammadAamirALi for simple layout examples, or from DonGru, Hema or Vinay for a bit more advanced static views.
Anyhow, as I said, this is just an intro for the SurfaceView approach...
Cheers!
PS.: Please, click here to see an index of other posts on Android.
No comments:
Post a Comment