I need a sample tutorial for the android SurfaceView
, or sample code using it that can be shared. The API demos are difficult for me to understand. Does anyone have alternatives?

- 20,545
- 20
- 91
- 102

- 965
- 4
- 11
- 16
-
1try this http://www.droidnova.com/playing-with-graphics-in-android-part-ii,160.html – Ahmed Aswani Jan 17 '12 at 12:08
-
read the documentations on android dev, there is a tutorial on what your looking for; if you can't understand that then u got to do your java basics – tom91136 Jan 30 '12 at 14:36
-
3I agree that the samples aren't the best source of information on SurfaceView for all cases. I am looking for the *simplest* implementation(s) of a functional SurfaceView, and am having trouble understanding what the minimum requirements are for a skeleton framework of drawing on a surface view. I've been looking at the Lunar Lander sample, but can't work out what's specific to the game, and what's required for using a SurfaceView. – BlueMonkMN Mar 04 '12 at 14:54
-
Download the LunarLander demo. There are tons of websites discussing it. – user432209 Mar 08 '11 at 16:48
-
1do u have any easy samples??? i'm new to android.. – saranya krishnan Mar 08 '11 at 16:55
-
It doesn't get a whole lot easier when it comes to a full game application. You have to devote the time and a game application is by far _not_ the easiest thing to learn. – user432209 Mar 11 '11 at 00:11
2 Answers
This commit of my WorldMap demo app shows you the changes necessary to convert from an android.view.View to an android.view.SurfaceView with an android.view.SurfaceHolder.Callback.
It cheats a bit by using the View
's onDraw()
from within the SurfaceView
's DrawThread
and by calling the View
's onSizeChanged()
from within the SurfaceView
's surfaceChanged
. It just makes the diff smaller and easier to understand.

- 12,700
- 11
- 57
- 61
-
crazy as (i believe) your solution is, it was the easiest fix for me, thanks :) – David O'Meara Mar 01 '13 at 03:10
-
I'm not sure if you're needing a GLSurfaceView
or not, but glbuffer is one of my favorite examples.
This is the java file where the action happens: GlBufferActivity
The project also relies on native methods and the NDK, so it may not be exactly what you're looking for, but it's a great starting point if you want to work with OpenGL via the normal C apis.

- 44,826
- 10
- 98
- 87
-
-
-
hey can i have three buttons over the surface view.. is it possible?? – saranya krishnan Mar 08 '11 at 17:06
-