Completely parse the original definition of surfaceview

Source: Internet
Author: User

Introduction to surfaceview APIs

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

Surfaceview is an inherited class of view, which is embedded with a surface dedicated for painting. You can control the format and size of the surface. Surfaceview controls the position of this surface.

 

The surface is Z ordered so that it is behind the window holding its surfaceview; The surfaceview punches a hole in its window to allow its surface to be displayed. the view hierarchy will take care of correctly compositing with the surface any siblings
Of the surfaceview that wowould normally appear on top of it. this can be used to place overlays such as buttons on top of the surface, though note however that it can have an impact on performance since a full alpha-blended composite will be placed med each
Time the surface changes.

Surface is ordered in depth (Z-ordered), which indicates that it is always behind its own window. Surfaceview provides a visible area where only the surface content in the visible area is visible and the area outside the visible area is invisible. The layout display of the surface is affected by the hierarchical view relationship, and its sibling view node is displayed at the top. This means that the content of the surface is blocked by its sibling view, which can be used to place overlays (for example, controls such as text and buttons ). Note: if there is a transparent control on the surface, every change to it will cause the framework to recalculate its transparency and the top-level control, which will affect the performance.

 

Access to the underlying surface is provided via the surfaceholder interface, which can be retrieved by calling getholder ().

You can access this surface through the surfaceholder interface. The getholder () method can obtain this interface.

The surface will be created for you while the surfaceview's window is visible; You shocould implement surfacecreated (surfaceholder) and surfacedestroyed (surfaceholder) to discover when the surface is created and destroyed as the window is shown and hidden.

When surfaceview becomes visible, the surface is created. Before surfaceview is hidden, the surface is destroyed. This saves resources. If you want to check the time when the surface is created and destroyed, you can reload surfacecreated (surfaceholder) and surfacedestroyed (surfaceholder ).

 

 

One of the purposes of this class is to provide a surface in which a secondary thread can render in to the screen. if you are going to use it this way, you need to be aware of some threading semantics:

The core of surfaceview is to provide two threads: the UI thread and the rendering thread. Note:

 

• All surfaceview and surfaceholder. callback methods will be called from the thread running the surfaceview's window (typically the main thread of the application ). they thus need to correctly synchronize with any State that is also touched by the drawing
Thread.
1> All surfaceview and surfaceholder. Callback methods should be called in the UI thread, which is generally the main thread of the application. Various variables accessed by the rendering thread should be processed synchronously.

• You must ensure that the drawing thread only touches the underlying surface while it is valid -- between surfaceholder. callback. surfacecreated () and surfaceholder. callback. surfacedestroyed (). 2> because the surface may be destroyed, it is only in surfaceholder. callback. surfacecreated () and surfaceholder. callback. surfacedestroyed () is valid, so make sure that the rendering thread accesses a valid surface.

 

 

 

 

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.