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
This code example shows how to use the following methods: setZOrderOnTop, setMediaController, setOnCompletionListener
78: _videoView = new VideoView(getActivity());
80: _videoView.setMediaController(new MediaController(getActivity()));
Full Snippet Info
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
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