Detailed explanation of Android view class and surfaceview class

In addition to the control class, the main class in Android game development is the display class. The more important and complex is the processing of display and game logic. In J2ME, display can be realized through display and canvas, while in Android, the view class handles display. Here is a brief introduction to Android view. View and Android view. SurfaceView。

Surfaceview is a display class derived from the view base class. Its direct subclasses include glsurfaceview and videoview. We can see that surfaceview is generally used by GL, video playback and camera cameras. What are the advantages? Surfaceview can control the format of the surface, such as the size and the position displayed on the screen. The most important thing is to provide the surfaceholder class, which can be obtained by using the getholder method. The relevant include canvas lockcanvas(), canvas lockcanvas (rect dirty), void removecallback (surfaceholder. Callback), void unlockcanvas andpost (canvas canvas canvas) to control graphics and rendering, And at surfaceholder The callback interface callback can define its own specific implementation through the following three abstract classes (for example, the first change of 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, the bottom layer of Android also provides GPU acceleration function, so generally, surfaceview is mainly used in applications with strong real-time performance rather than built directly from view. At the same time, glsurfaceview in OpenGL, which will be mentioned later, is also implemented from this class.

The above is a detailed introduction to Android view class and surface class. I hope to help Android developers. Thank you for your support for this site. Continue to supplement relevant materials in the future.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>