|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.view.View
android.view.SurfaceView
public class SurfaceView
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.
Access to the underlying surface is provided via the SurfaceHolder interface,
which can be retrieved by calling getHolder().
The Surface will be created for you while the SurfaceView's window is
visible; you should implement SurfaceHolder.Callback.surfaceCreated(android.view.SurfaceHolder)
and SurfaceHolder.Callback.surfaceDestroyed(android.view.SurfaceHolder) 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 in to the screen. If you are going to use it this way, you need to be aware of some threading semantics:
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.
SurfaceHolder.Callback.surfaceCreated()
and
SurfaceHolder.Callback.surfaceDestroyed().
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class android.view.View |
|---|
View.AttachInfo, View.BaseSavedState, View.CheckForLongPress, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener |
| Field Summary | |
|---|---|
(package private) static int |
GET_NEW_SURFACE_MSG
|
(package private) static int |
KEEP_SCREEN_ON_MSG
|
(package private) ArrayList<SurfaceHolder.Callback> |
mCallbacks
|
(package private) Rect |
mCoveredInsets
|
(package private) boolean |
mDestroyReportNeeded
|
(package private) boolean |
mDrawingStopped
|
(package private) int |
mFormat
|
(package private) Handler |
mHandler
|
(package private) boolean |
mHaveFrame
|
(package private) int |
mHeight
|
(package private) boolean |
mIsCreating
|
(package private) long |
mLastLockTime
|
(package private) WindowManager.LayoutParams |
mLayout
|
(package private) int |
mLeft
|
(package private) boolean |
mNewSurfaceNeeded
|
(package private) int |
mRequestedFormat
|
(package private) int |
mRequestedHeight
|
(package private) int |
mRequestedType
|
(package private) boolean |
mRequestedVisible
|
(package private) int |
mRequestedWidth
|
(package private) IWindowSession |
mSession
|
(package private) Surface |
mSurface
|
(package private) Rect |
mSurfaceFrame
|
(package private) ReentrantLock |
mSurfaceLock
|
(package private) int |
mTop
|
(package private) int |
mType
|
(package private) boolean |
mVisible
|
(package private) int |
mWidth
|
(package private) android.view.SurfaceView.MyWindow |
mWindow
|
(package private) Rect |
mWinFrame
|
| Constructor Summary | |
|---|---|
SurfaceView(Context context)
|
|
SurfaceView(Context context,
AttributeSet attrs)
|
|
SurfaceView(Context context,
AttributeSet attrs,
int defStyle)
|
|
| Method Summary | |
|---|---|
protected void |
dispatchDraw(Canvas canvas)
Called by draw to draw the child views. |
void |
draw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas. |
boolean |
gatherTransparentRegion(Region region)
This is used by the RootView to perform an optimization when the view hierarchy contains one or several SurfaceView. |
SurfaceHolder |
getHolder()
Return the SurfaceHolder providing access and control over this SurfaceView's underlying surface. |
(package private) void |
handleGetNewSurface()
|
protected void |
onAttachedToWindow()
This is called when the view is attached to a window. |
protected void |
onDetachedFromWindow()
This is called when the view is detached from a window. |
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
Measure the view and its content to determine the measured width and the measured height. |
protected void |
onScrollChanged(int l,
int t,
int oldl,
int oldt)
This is called in response to an internal scroll in this view (i.e., the view scrolled its own contents). |
protected void |
onSizeChanged(int w,
int h,
int oldw,
int oldh)
This is called during layout when the size of this view has changed. |
protected void |
onWindowVisibilityChanged(int visibility)
Called when the window containing has change its visibility (between View.GONE, View.INVISIBLE, and View.VISIBLE). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
final ArrayList<SurfaceHolder.Callback> mCallbacks
final ReentrantLock mSurfaceLock
final Surface mSurface
boolean mDrawingStopped
final WindowManager.LayoutParams mLayout
IWindowSession mSession
android.view.SurfaceView.MyWindow mWindow
final Rect mWinFrame
final Rect mCoveredInsets
static final int KEEP_SCREEN_ON_MSG
static final int GET_NEW_SURFACE_MSG
boolean mIsCreating
final Handler mHandler
boolean mRequestedVisible
int mRequestedWidth
int mRequestedHeight
int mRequestedFormat
int mRequestedType
boolean mHaveFrame
boolean mDestroyReportNeeded
boolean mNewSurfaceNeeded
long mLastLockTime
boolean mVisible
int mLeft
int mTop
int mWidth
int mHeight
int mFormat
int mType
final Rect mSurfaceFrame
| Constructor Detail |
|---|
public SurfaceView(Context context)
public SurfaceView(Context context,
AttributeSet attrs)
public SurfaceView(Context context,
AttributeSet attrs,
int defStyle)
| Method Detail |
|---|
public SurfaceHolder getHolder()
protected void onAttachedToWindow()
ViewView.onDraw(android.graphics.Canvas), however it may be called
any time before the first onDraw -- including before or after
View.onMeasure(int, int).
onAttachedToWindow in class ViewView.onDetachedFromWindow()protected void onWindowVisibilityChanged(int visibility)
ViewView.GONE, View.INVISIBLE, and View.VISIBLE). Note
that this tells you whether or not your window is being made visible
to the window manager; this does not tell you whether or not
your window is obscured by other windows on the screen, even if it
is itself visible.
onWindowVisibilityChanged in class Viewvisibility - The new visibility of the window.protected void onDetachedFromWindow()
View
onDetachedFromWindow in class ViewView.onAttachedToWindow()
protected void onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
View
Measure the view and its content to determine the measured width and the
measured height. This method is invoked by View.measure(int, int) and
should be overriden by subclasses to provide accurate and efficient
measurement of their contents.
CONTRACT: When overriding this method, you
must call View.setMeasuredDimension(int, int) to store the
measured width and height of this view. Failure to do so will trigger an
IllegalStateException, thrown by
View.measure(int, int). Calling the superclass'
View.onMeasure(int, int) is a valid use.
The base class implementation of measure defaults to the background size,
unless a larger size is allowed by the MeasureSpec. Subclasses should
override View.onMeasure(int, int) to provide better measurements of
their content.
If this method is overridden, it is the subclass's responsibility to make
sure the measured height and width are at least the view's minimum height
and width (View.getSuggestedMinimumHeight() and
View.getSuggestedMinimumWidth()).
onMeasure in class ViewwidthMeasureSpec - horizontal space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec.heightMeasureSpec - vertical space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec.View.getMeasuredWidth(),
View.getMeasuredHeight(),
View.setMeasuredDimension(int, int),
View.getSuggestedMinimumHeight(),
View.getSuggestedMinimumWidth(),
View.MeasureSpec.getMode(int),
View.MeasureSpec.getSize(int)
protected void onScrollChanged(int l,
int t,
int oldl,
int oldt)
ViewView.scrollBy(int, int) or View.scrollTo(int, int) having been
called.
onScrollChanged in class Viewl - Current horizontal scroll origin.t - Current vertical scroll origin.oldl - Previous horizontal scroll origin.oldt - Previous vertical scroll origin.
protected void onSizeChanged(int w,
int h,
int oldw,
int oldh)
View
onSizeChanged in class Vieww - Current width of this view.h - Current height of this view.oldw - Old width of this view.oldh - Old height of this view.public boolean gatherTransparentRegion(Region region)
View
gatherTransparentRegion in class Viewregion - The transparent region for this ViewRoot (window).
public void draw(Canvas canvas)
ViewView.onDraw(android.graphics.Canvas).
draw in class Viewcanvas - The Canvas to which the View is rendered.protected void dispatchDraw(Canvas canvas)
View
dispatchDraw in class Viewcanvas - the canvas on which to draw the viewvoid handleGetNewSurface()
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||