Android game development 2: View and surfaceview

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.