當 SurfaceView 的窗口可見時,將為您創建 Surface;應該實現 SurfaceHolder.Callback#surfaceCreated 和 SurfaceHolder.Callback#surfaceDestroyed 以發現在顯示和隱藏窗口時創建和銷毀 Surface 的時間。此類的目的之一是提供一個表面,輔助線程可以在其中渲染到屏幕中。 如果要以這種方式使用它,則需要了解一些線程語義。
Android SurfaceView 和 SurefaceHolder 關係 |
SurfaceView(Context context) |
SurfaceView(Context context, AttributeSet attrs) |
SurfaceView(Context context, AttributeSet attrs, int defStyleAttr) |
SurfaceView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) |
SurfaceView Public methods Class Parameters 類參數屬性:
Public methods |
|
void |
Manually render this view (and all of its children) to the given Canvas. |
boolean |
gatherTransparentRegion(Region region) This is used by the ViewRoot to perform an optimization when the view hierarchy contains one or several SurfaceView. |
SurfaceHolder
|
Return the SurfaceHolder providing access and control over this SurfaceView's underlying surface. |
IBinder
|
A token used for constructing SurfaceControlViewHost. |
int |
getImportantForAccessibility() Gets the mode for determining whether this View is important for accessibility. |
SurfaceControl
|
Return a SurfaceControl which can be used for parenting Surfaces to this SurfaceView. |
void |
setAlpha(float alpha) Sets the opacity of the view to a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque. |
void |
setChildSurfacePackage(SurfaceControlViewHost.SurfacePackage p) Display the view-hierarchy embedded within a SurfaceControlViewHost.SurfacePackage within this SurfaceView. |
void |
setClipBounds(Rect clipBounds) Sets a rectangular area on this view to which the view will be clipped when it is drawn. |
void |
setSecure(boolean isSecure) 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. |
void |
setVisibility(int visibility) Set the visibility state of this view. |
void |
setZOrderMediaOverlay(boolean isMediaOverlay) 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). |
void |
setZOrderOnTop(boolean onTop) Control whether the surface view's surface is placed on top of its window. |
SurfaceView Protected methods Class Parameters類參數屬性:
Protected methods |
|
void |
dispatchDraw(Canvas canvas) Called by draw to draw the child views. |
void |
This is called when the view is attached to a window. |
void |
This is called when the view is detached from a window. |
void |
onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) Called by the view system when the focus state of this view changes. |
void |
onMeasure(int widthMeasureSpec, int heightMeasureSpec) Measure the view and its content to determine the measured width and the measured height. |
Void |
onWindowVisibilityChanged(int visibility) Called when the window containing has change its visibility (between GONE, INVISIBLE, and VISIBLE). |
沒有留言:
張貼留言