Surfaceview is a display class derived from the view base class. Its direct sub-classes include glsurfaceview and videoview. It can be seen that Gl, video playback, and camera cameras generally use surfaceview. What are the advantages? Surfaceview can control the surface format, such as the size and position of the display on the screen. The most important thing is to provide the surfaceholder class, which is obtained using the getholder method and related to canvas lockcanvas (), canvas lockcanvas (rect dirty), void removecallback (surfaceholder. callback
Callback), void unlockcanvasandpost (canvas) controls graphics and painting, while in surfaceholder. in the callback of the callback interface, you can use the following three abstract classes to define the specific implementation (for example, the first to change the format and display screen ):
Abstract void surfacechanged (surfaceholder holder, int format, int width, int height );
Abstract void surfacecreated (surfaceholder holder );
Abstract void surfacedestroyed (surfaceholder holder );
For surface-related applications, the android underlying layer also provides GPU acceleration. Therefore, surfaceview is generally used in highly real-time applications rather than directly built from view, the glsurfaceview in OpenGL is also implemented in this class.