Best code examples for Android SurfaceView class (android.view.SurfaceView)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SurfaceView class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android SurfaceView examples from Open Source projects
Examples using Android SurfaceView getHolder method:
This code example shows how to use the following methods: getHolder, setLayoutParams
61:	mSurfaceView = new SurfaceView(this); 
62:	mSurfaceView.setLayoutParams(surfaceParams); 
-
77:	mSurfaceHolder = mSurfaceView.getHolder(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getHolder, setFocusable, setFocusableInTouchMode, setOnTouchListener
173:	mPreview = new SurfaceView(this); 
-
182:	mPreview.setFocusable(true); 
183:	mPreview.setFocusableInTouchMode(true); 
184:	mPreview.setOnTouchListener(this); 
-
187:	mHolder = mPreview.getHolder(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getHolder
48:	mHolder = mSurfaceView.getHolder(); 
Full Snippet Info
7
CodeRank
Examples using Android SurfaceView setZOrderOnTop method:
This code example shows how to use the following methods: setZOrderOnTop, setMediaController, setOnCompletionListener
78:	_videoView = new VideoView(getActivity()); 
79:	_videoView.setZOrderOnTop(true); 
80:	_videoView.setMediaController(new MediaController(getActivity())); 
81:	_videoView.setOnCompletionListener(this); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getHolder, setZOrderOnTop, setEGLConfigChooser, setEGLContextClientVersion, setRenderMode
56:	surfaceView = new GLSurfaceView(this); 
57:	surfaceView.setEGLContextClientVersion(2); 
-
60:	surfaceView.setEGLConfigChooser(8, 8, 8, 8, 0, 0); 
61:	surfaceView.setZOrderOnTop(true); 
62:	surfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT); 
-
64:	surfaceView.setRenderer(this); 
65:	surfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getHolder, setZOrderOnTop, bringChildToFront, getParent, setEGLConfigChooser
27:	glView = new GLSurfaceView(this); 
-
29:	glView.setEGLContextClientVersion(2); 
-
31:	glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); 
-
33:	glView.setRenderer(new MyGLRenderer()); 
-
38:	glView.getHolder().setFormat(PixelFormat.TRANSLUCENT); 
-
40:	glView.setZOrderOnTop(true); 
-
47:	glView.getParent().bringChildToFront(glView); 
Full Snippet Info
6
CodeRank
Examples using Android SurfaceView setVisibility method:
This code example shows how to use the following methods: getHolder, setVisibility, setLayoutParams
154:	surfaceView.setVisibility(View.VISIBLE); 
-
235:	surfaceView = new SurfaceView(currentActivity); 
236:	surfaceView.getHolder().addCallback(new SurfaceViewCallback()); 
237:	surfaceView.setVisibility(View.GONE); 
-
240:	surfaceView.setLayoutParams(params); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setVisibility, setMediaController, setVideoURI, start
196:	mVideoView.setVideoURI(mVideoUri); 
-
198:	mVideoView.setVisibility(View.VISIBLE); 
199:	mVideoView.setMediaController(new MediaController(this)) ; 
200:	mVideoView.start(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getHolder, setZOrderMediaOverlay, setEGLConfigChooser, setEGLContextClientVersion, setRenderer
26:	mGLView.setEGLContextClientVersion(2); 
27:	mGLView.setEGLConfigChooser(8, 8, 8, 8, 16, 0); 
28:	mGLView.setRenderer(new OpenGLRenderer(mainInterface)); 
29:	mGLView.getHolder().setFormat(PixelFormat.TRANSLUCENT); 
30:	mGLView.setZOrderMediaOverlay(true); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setZOrderMediaOverlay, setEGLContextClientVersion, setRenderer
117:	mGLSurfaceView = new GLSurfaceView(this); 
-
124:	mGLSurfaceView.setEGLContextClientVersion(2); 
-
135:	mGLSurfaceView.setRenderer(mRenderer); 
-
144:	mGLSurfaceView.setZOrderMediaOverlay(true); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setZOrderMediaOverlay, setLayoutParams, setOnTouchListener, setRenderer
39:	glSurface = new GLSurfaceView(this); 
-
41:	glSurface.setRenderer(render); 
42:	glSurface.setOnTouchListener(render); 
-
60:	glSurface.setZOrderMediaOverlay(true); 
61:	glSurface.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 
Full Snippet Info
6
CodeRank
Examples for other Android SurfaceView methods:
Related Android SurfaceView Questions & Answers:
SurfaceView Class Overview
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 getHolder(). The Surface will be created for you while the SurfaceView's window is visible; you should implement surfaceCreated(SurfaceHolder) and surfaceDestroyed(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 into the screen. If you are going to use it this way, you need to be aware of some threading semantics: 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. You must ensure that the drawing thread only touches the underlying Surface while it is valid -- between SurfaceHolder.Callback.surfaceC...
Methods
  • draw
    Manually render this view (and all of its children) to the given Canvas.
  • getHolder
    Return the SurfaceHolder providing access and control over this SurfaceView's underlying surface.
  • setZOrderMediaOverlay
    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
    Control whether the surface view's surface is placed on top of its window.