SurfaceView is a widget on the Android platform which provides a dedicated drawing surface.
Android's SurfaceView class provides a dedicated drawing surface embedded inside of a View hierarchy. You can control the format of this surface and, if you like, its size; the SurfaceView takes care of placing the surface at the correct location on the screen.
A SurfaceView has two parts: the Surface, and the View. The Surface is a separate layer, independent of the View UI layer; by default it is positioned behind the View layer. The View works like any other View element, and is usually completely transparent, serving only to interact with other View elements during layout. In some situations it can be useful to draw on the View (e.g. for a static mask).
Because the Surface is an independent layer, it can be updated outside of the usual invalidate/refresh View cycle, on a dedicated thread.
Allocation of a display Surface is performed by the Window Manager. This requires an IPC round-trip, so the availability of and changes to Surfaces are reported through callbacks. This also makes it difficult to move a SurfaceView around smoothly, as the position of the View and position of the Surface may not update on the same frame.
Other View elements can be positioned to overlap the SurfaceView, including interactive elements like buttons. The Surface's Z-order can be altered to place it on top of the View layer. It isn't possible to sandwich the Surface between View elements; if you need that, consider TextureView instead.
The transparent region that makes the surface visible is based on the layout positions in the view hierarchy. If the post-layout transform properties are used to draw a sibling view on top of the SurfaceView, the view may not be properly composited with the surface.
For many applications, a custom view is a better choice.
Detailed information about SurfaceView can be found in the system-level graphics architecture document.