surfaceview

subclassing SurfaceView and overriding onDraw() to change SurfaceView parameters to generate preview of desired size

I have subclassed the SurfaceView and instantiating it in onCreate of the Activity. The preview is generated but the control never enters onDraw() which is overriden in the subclass of SurfaceView. Why is that? class ActivityClass extends Activity{ onCreate(){ mPreview = new Preview(this); setContentView(mPreview); } public void st...

overriding dispatchDraw(Canvas) in subclass of SurfaceView

What exactly does dispatchDraw(Canvas) method do? This is what the documentation says: protected void dispatchDraw (Canvas canvas) Since: API Level 1 Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn). Parameters c...

android view or surfaceView, which should i use?

Ive been trying to make a scrollable/zoomable app and everything has gone great except for drawing bitmaps. It is a very large image (6656 by 4096) that i have split into tiles. There is a rectangle array that the bitmaps are drawn to, and it detects what rectangle is in the top left corner so it can draw the bitmaps that will cover the ...

Adding GestureOverlayView to my SurfaceView class, how to add to view hierarchy?

I was informed in a later answer that I have to add the GestureOverlayView I create in code to my view hierarchy, and I am not 100% how to do that. Below is the original question for completeness. I want my game to be able to recognize gestures. I have this nice SurfaceView class that I do an onDraw to draw my sprites, and I have a th...

Android OpenGL extending GLSurfaceView null pointer exceptions

I am trying to create a simple 3-D app for android that will have an additional view layered on top of the OpenGL view (much like the SurfaceViewOverlay example in the API demos). I'm running into an issue trying to implement that method with an extended GLSurfaceView class. I've set up an example where I'm trying to do a combination of ...

How to have a transparent ImageButton: Android

<ImageButton android:id="@+id/previous" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/media_skip_backward" android:background="@drawable/transparent"></ImageButton> This is what I tried to get a transparent ImageButton so as to place those buttons on a SurfaceView. But Eclipse, gives me...

Animation on Surface View Android

I'm making a game with 5 objects moving around on the screen with SurfaceView. It's not a problem until a display all 5 objects to the screen. It displays a black screen. Any suggestion? I'm using SurfaceView and use onDraw() to draw bitmaps. ...

Using ViewGroup.addView() to add a GestureOverlayView to a SurfaceView game panel.

After much help from the good people here, I finally almost got my little game panel (thats a surfaceview class) up and running with a GestureOverlayView. Through the use of addView I finally was able to add the GestureOverlayView and get it to work, the trouble is that calling this: /** create the login form */ private ViewGroup _...

Update Android SurfaceView on-the-fly with new elements

I have a database filled with records in the following format: . What I want my application to do is select records from an external database, and display those records on the phone screen using a SurfaceView. Currently, I have an Activity, and a Service responsible for the record-gathering portion of the application. The Activity pass...

Possible to start a SurfaceView with a Game Thread anytime other than at startup of the program?

Hello everyone, I've read several example programs and tutorials to try and solve my problem but they all seem to go the same way. I've used a couple Activities and xml documents to create a menu that loads when my game starts. When the user clicks the "Start The Game" button, it loads a new Activity that sets the view with my game th...

Possible to start a SurfaceView with a Game Thread anytime other than at startup of the program?

Hello everyone, I've read several example programs and tutorials to try and solve my problem but they all seem to go the same way. I've used a couple Activities and xml documents to create a menu that loads when my game starts. When the user clicks the "Start The Game" button, it loads a new Activity that sets the view with my game th...

passing variables to an outside class.

I split my inner View class from my Main class into its own file. In my main class, I have the view set as an onTouchListener which records user movement into a matrix so it can translate and scale the view. After separating it everything works but im unsure how to pass the matrix to the View for onDraw to update. Any suggestions? Thanks...

Android: Cannot see video on HTC Hero 1.5

I am trying to play a video through my application. public class VideoScreen extends Activity { public MediaPlayer videoMediaPlayer = new MediaPlayer(); public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.videoscreen); SurfaceView demoVideo = (SurfaceView) fi...

Creating AlertDialog with Static Methods?

I've completed most of the game I'm attempting to make and throughout the project I've created one particular Activity which also calls a SurfaceView and a Thread. I put an update() method in each of the 3 classes so they each know where the other ones are everytime something changes. Apparently, the only way to do something like this ...

Recycling bitmaps/managing memory effectively.

I have a tile based image viewer which scrolls and zooms. Everything works fine...but when the gc fires up there is a bit of a lag I want to get rid of. At the moment, I have no recycling method to my bitmaps for the tiles not onscreen anymore. Would it make a difference if I did recycle the bitmaps once they go off screen using recy...

Strange behavior with a low thread priority.

I have 2 threads, one that decodes bitmaps from the assetManager, and another that is my SurfaceView. When i set the priority of the bitmap decoder very low, i actually get more lag then if its much higher. Why would it act like that? thanks. Heres my code: public void bitmapLoader(final String filePath,final int pathVariable) ...

What happens in the system when canvas.drawBitmap is called?

I have a scrollable and zoomable map which has a low res copy of the map which is drawn when the zoom scale is small and a tile system when the user zooms in past a certain point. The problem im having is that the very first time the tiles are drawn there is a short, but noticable lag. After that initial lag everything is smooth. The GC ...

how to pause and resume a surfaceView thread.

I have a surfaceView setup and running, but when i resume it i get an error that the thread has already been started. Whats the proper way to handle when the app goes to the background and then back to the foreground? Ive tinkered around and managed to get the app to come back without crashing...but the surfaceView doesnt draw anthing an...

SurfaceView vs Custom View (extended from View). SurfaceView is slower, Why?

I wrote the same program two ways. One using a Surfaceview, and the other using a custom view. According to the android SDK development guide, using a surface view is better because you can spawn a separate thread to handle graphics. Th SDK development guide claims that using a custom view with invalidate calls is only good for slower a...

SurfaceView.setbackground() dominates my canvas

When I set the background to my surfaceview, I see what I set as the background. However, I cannot draw simple things like circles when I lock/unlock the surfaceview's canvas. All I see is the background image. Is there something I'm missing? Any thoughts? ...