Questions tagged [surfaceview]

SurfaceView is a widget on the Android platform which provides a dedicated drawing surface.

Android's SurfaceView class 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.

A SurfaceView has two parts: the Surface, and the View. The Surface is a separate layer, independent of the View UI layer; by default it is positioned behind the View layer. The View works like any other View element, and is usually completely transparent, serving only to interact with other View elements during layout. In some situations it can be useful to draw on the View (e.g. for a static mask).

Because the Surface is an independent layer, it can be updated outside of the usual invalidate/refresh View cycle, on a dedicated thread.

Allocation of a display Surface is performed by the Window Manager. This requires an IPC round-trip, so the availability of and changes to Surfaces are reported through callbacks. This also makes it difficult to move a SurfaceView around smoothly, as the position of the View and position of the Surface may not update on the same frame.

Other View elements can be positioned to overlap the SurfaceView, including interactive elements like buttons. The Surface's Z-order can be altered to place it on top of the View layer. It isn't possible to sandwich the Surface between View elements; if you need that, consider TextureView instead.

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.

For many applications, a custom view is a better choice.

Detailed information about SurfaceView can be found in the system-level graphics architecture document.

2733 questions
1
vote
1 answer

How to update a surfaceview encapsulated in a Framelayout?

i have a surfaceview update problem. I would like to create a lightweight augmented reality app, so i made a framelayout with camerapreview in the back, and an extended surfaceview on the front. alParent = new FrameLayout(this); …
paland3
  • 61
  • 5
1
vote
1 answer

Android surface canvas.drawRect has a decaying shadow effect

I'm writing an Android app which uses custom draw on SurfaceView and I'm getting a decaying shadow effect when i move the object (currently a rect). Below is portion of my code. canvas = _surfaceHolder.lockCanvas(null); if (canvas != null)…
faulty
  • 8,117
  • 12
  • 44
  • 61
1
vote
1 answer

Activity vs. View. vs. SurfaceView and interaction

I am trying to make a fairly simple Android game. I am making a custom view: I am not using any buttons, rather, I am painting pixels on screen that represent buttons. The idea is that I have 3 screens: A Main screen A Play screen An Instructions…
1
vote
3 answers

Explosion animation

I want to do an explosion animation with three different bitmaps representing different stages of the explosion I already have the bitmaps loaded, I tried using a for loop but the images get by too fast to see. I have this all in my surfaceview…
kabuto178
  • 3,129
  • 3
  • 40
  • 61
1
vote
1 answer

android Screen Capture

i want to capture the video screen as image from videoview in android..my code is given below.its create the image but that image contains only blackscreen in sdcard.how to capture the videoview as image while playing. public class…
android
  • 51
  • 3
  • 12
1
vote
2 answers

How to show SurfaceView on Lock Screen?

I'm working to implement a lock screen just like the water ripple lock screen of Samsung Galaxy 3. I have finished the GLSurfaceView object. But there is a problem when I port it to Lock Screen. The SurfaceView couldn't be displayed on Lock Screen…
1
vote
0 answers

Thread is to be running if surfaceDestroyed() is called when home button is pressed

I am new to android Surfaceview implementation. I am developing RDP client application in android3.0. I getting the image stream from socket, drawing this image to surface using Surfaceview and Thread. The sample code of surface view: class…
mini
  • 855
  • 4
  • 15
  • 22
1
vote
1 answer

Starting new activity triggered by boolean in GameThread (android)

I am making a "Defend the castle" style android application. The game is complete, however I just need help closing my surfaceview and starting a new activity for when the the player has lost the game. The condition for losing the game is just a…
Mike
  • 537
  • 2
  • 6
  • 20
1
vote
0 answers

SurfaceView showing blank white screen

I am trying to draw an oval to the screen but all I am getting is a blank white canvas. Not only am I unsure whether I am drawing the oval correctly, but also am getting nothing to the screen. Does anyone know why this is happening, I think the…
jister13
  • 83
  • 1
  • 9
1
vote
2 answers

Pass data from main activity to SurfaceView thread using a seek bar

I have a main activity class, I've also got a SurfaceView class that starts when my main activity starts. I've got a seek bar in the main activity. I'd like to send whatever data that the seek bar produces to the SurfaceView to show it, every time…
user1319668
  • 329
  • 1
  • 4
  • 16
1
vote
2 answers

Accessing the Android camera for a live video

public SurfaceHolder sh; public Display(Context context) { super(context); sh = getHolder(); sh.addCallback(this); sh.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } I am trying to access the camera for…
Monisha
  • 11
  • 1
1
vote
4 answers

Camera preview is completely black after screen off, screen on

I'm working with the CameraPreview in the API Demos that comes with the Android SDK. While the camera preview is running, if I turn off my screen and turn it on again, the camera preview is completely black. The device's camera application somehow…
Karakuri
  • 38,365
  • 12
  • 84
  • 104
1
vote
1 answer

SurfaceView not clearing old Photo

I have this SurfaceView and when I drag a bar the zoomController increases, and when I drag it the other way the zoomController decreases. The effect is to enlarge and shrink the photo, the problem I am having is that the old photo stays so if I…
jister13
  • 83
  • 1
  • 9
1
vote
1 answer

Substitution of queueEvent when not using GLSurfaceView

When controlling OpenGL from other threads, if it is GLSurfaceView, we use queueEvent(). Then, in cases where OpenGL is created on SurfaceView (use eglCreateWindowSurface, eglMakeCurrent, etc.), how should I implement for operating OpenGL from other…
Tank2005
  • 899
  • 1
  • 14
  • 32
1
vote
1 answer

Image taken with custom camera using surfaceview on android 4.0 powered devices(like Galaxy s3) is showing less resolution

I am developing an app, in that I am using Surfaceview and Camera api to take picture. My problem is the resolution of Image taken using Galaxy S3 is showing only 640x480. But in other devices it is showing the resolution as per the camera. Because…
Aju
  • 4,597
  • 7
  • 35
  • 58