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
0 answers

Android Live Video Processing Using Open GL

I am trying to do live video processing on Android 4.03 using OpenGL ES. So for example i would like to get a live video feed and display it on the screen with custom modifications, such as only drawing the red component of the video. I have no…
1
vote
3 answers

SurfaceView.lockCanvas() does not properly clear the bitmap buffer

I have created a class that extends SurfaceView in order to cycle a series of ARGB bitmaps. This mostly works, except that the state of the underlying bitmap is (usually, but not always) preserved for each new frame. In other words, if the first…
Stu
  • 1,999
  • 1
  • 14
  • 11
1
vote
1 answer

Android Surfaceview thread not response

I have a problem with a thread in surfaceview. I can't understand how to onPause/onResume when I lock my phone. Whatever I do, the thread doesn't respond after locking/unlocking the phone. In the activity: @Override protected void onResume() { …
Anton Sobolev
  • 135
  • 2
  • 3
  • 11
1
vote
1 answer

Android GUI overlaying

I am new to android. Some time ago I saw application "Cracked Screen". It makes a screenshot of the screen, then adds a transparent "cracked" sprite and display it. Can I do something similar without screenshoting? That is to display the sprite on…
Risdecs
  • 103
  • 5
1
vote
2 answers

is canvas in android proportional on different devices

I am trying to make an app using canvas and a surfaceview, and I am worrying that in the future I would have many problems with it because I am not sure if the canvas is proportional with every device. currently I can only use my emulator since my…
Baruch
  • 1,618
  • 5
  • 23
  • 42
1
vote
0 answers

fix aspect ration of size of SurfaceView to fix as 4:3 in Android when screenOrientation chages

In my android application,SurfaceView is size of (320*240, 4:3) in when screenOrientation is landscape mode. When i rotate mob to portrait mode, SurfaceVeiw gets size of (240,340),how can i force SurfaceView to maintain aspect ration of 4:3 when…
1
vote
0 answers

SurfaceView - Bitmap's are glitchy when detecting input

I've created a game loop in Android by extending the SurfaceView class and the Thread class similar to the Lunar Lander example in the Android Samples. Right now I'm just trying to find a way to let users drag Bitmaps around the screen using…
Sam Jackson
  • 608
  • 1
  • 5
  • 13
1
vote
0 answers

Android : All SurfaceView gets full screen after I rotate mobile instead of maintaining aspect ration 4:3,

In my android application i am showing video (frame by frame) using SurfacView,i am showing 2,3,4 SurfaceView (videos) in one screen. Video (Surfaceview) appear as per remote user start their web came(desktop application). I have used…
1
vote
1 answer

Simple game bug

I write a simple game with the following structure. Main xml layout have user View:
Leo
  • 3,003
  • 5
  • 38
  • 61
1
vote
2 answers

SurfaceView Animation

From what I've read I don't believe a SurfaceView can be animated but I'll ask the question: I have a surfaceView object inside a ViewFlipper. When the ViewFlipper is animated left or right to a new "page", the SurfaceView from the prior page…
Batdude
  • 556
  • 7
  • 19
1
vote
1 answer

how to initialize a custom surfaceView given that its a nested class in an activity?

I have a custom SurfaceView that looks like this: public class GFXSurface extends Activity implements OnTouchListener { . . GameSurface gameSurfaceView; @Override protected void onCreate(Bundle savedInstanceState) { …
Leon
  • 55
  • 1
  • 8
1
vote
1 answer

Android Threaded Surfaceview Does not Refresh

I coded a threaded surfaceview. It works but does not seem to refresh well. What I mean by not refresh well is EX: If I move a bitmap position it continues to be drawn at is last location + is a new one. Here is my code: public GameView(Context…
1
vote
2 answers

Trying to start a new activity when the screen is touched

I'm trying to start a new activity when the screen is touched.The background is a resized bitmap. But the touch is not detected. Here's my code: public class DispCover extends Activity implements OnTouchListener{ @Override public void…
1
vote
3 answers

looping android method

I am making an android game. I am using RelativeLayout, which hosts a FrameLayout, which hosts a SurfaceView. However, i have added a textview onto the RelativeLayout to show how many health points the player has left. I have a method which sets the…
user1446632
  • 417
  • 2
  • 9
  • 24
1
vote
0 answers

How to move a SurfaceView with transparent background?

I have an activity class, which I want to show a small dynamic content with translucent background on top of a main content, that is something like a moving overlay. I use a SurfaceView descendant for this purpose. For the simplicity I'm trying to…
Stan
  • 8,683
  • 9
  • 58
  • 102
1 2 3
99
100