0

Can anyone explain me what is android SurfaceView? I have been trough the android development web site and read about and i cant still understand it.

Why or when is it use in android application development.Maybe a good example if possible

Thank you

murielK
  • 1,000
  • 1
  • 10
  • 21
  • Mostly for graphics like OpenGL, VideoView is SurfaceView based, Camera preview etc. – Stan Feb 10 '14 at 17:26
  • have a look at this question: http://stackoverflow.com/questions/1243433/android-difference-between-surfaceview-and-view – migos Feb 10 '14 at 17:32
  • Another link: http://stackoverflow.com/questions/21305651/textureview-vs-glsurfaceview-or-how-to-use-glsurfaceview-with-egl14/21322600#21322600 – fadden Feb 10 '14 at 17:34

2 Answers2

1

Android SurfaceView is an object that is associated with a window (but behind a window), using which you can directly manipulate the canvas and draw whatever you like.

What is interesting about the implementation of SurfaceView is that although it lies BEHIND a window, as long as it has any content to show, Android framework will let the corresponding pixels on that window to be transparent, thus making the surface view visible.

It is most likely to be used for building a game or browser, where you want a graphical renderer to calculate pixels for you while you can also use java code to control the normal APP logic.

If you are new to normal Android programming, chances are you do not need to know too much about it.

For further information, see this and the official documentation.

Ian Wong
  • 1,617
  • 14
  • 11
0

View or SurfaceView comes into picture when you need custom design in the android layout instead of using existing android widgets provided from android. Here the main difference of View and SurfaceView is drawing threads. View is drawn in the UI thread and SurfaceView can be drawn in a separate thread.

Therefore SurfaceView is more appropriate when it requires to update UI rapidly or rendering takes too much time (eg: animations, video playback, camera preview etc..)

Sachini Samarasinghe
  • 1,081
  • 16
  • 18