Android Guides | Samples

Android.Views.SurfaceView Class

Provides a dedicated drawing surface embedded inside of a view hierarchy.

See Also: SurfaceView

Syntax

[Android.Runtime.Register("android/view/SurfaceView", DoNotGenerateAcw=true)]
public class SurfaceView : View

Remarks

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

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 would 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 performed each time the Surface changes.

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.

Access to the underlying surface is provided via the SurfaceHolder interface, which can be retrieved by calling SurfaceView.Holder.

The Surface will be created for you while the SurfaceView's window is visible; you should implement ISurfaceHolderCallback.SurfaceCreated(ISurfaceHolder) and ISurfaceHolderCallback.SurfaceDestroyed(ISurfaceHolder) to discover when the Surface is created and destroyed as the window is shown and hidden.

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

[Android Documentation]

Requirements

Namespace: Android.Views
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Views.SurfaceView are listed below.

See Also: View

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

[read-only]
HolderISurfaceHolder. Return the SurfaceHolder providing access and control over this SurfaceView's underlying surface.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

GatherTransparentRegion(Region) : Boolean
This is used by the RootView to perform an optimization when the view hierarchy contains one or several SurfaceView.
SetSecure(Boolean)
Control whether the surface view's content should be treated as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays.
SetZOrderMediaOverlay(Boolean)
Control whether the surface view's surface is placed on top of another regular surface view in the window (but still behind the window itself).
SetZOrderOnTop(Boolean)
Control whether the surface view's surface is placed on top of its window.