Android Multiple SurfaceViews

You can have multiple SurfaceViewsin one layout. The “Multi-surface test” activity in Grafika has three. The first post cited in @nonsleepr’s answer was followed up 9 months later with this post by the same author, which mentioned the existence of SurfaceView#setZOrderMediaOverlay(). The key thing to understand is that SurfaceView is not a regular view. When … Read more

Should the renderingThread of a SurfaceView have the same life-cycle as the view or the activity?

The Activity and the View are created at essentially the same time. The Surface is created later, and that’s what the SufaceHolder callbacks are for. You can’t render on the Surface before it exists or after it’s destroyed, so there’s no point in starting your rendering thread before then or leaving it running after. The … Read more

How to resize a bitmap eficiently and with out losing quality in android

Resizing a Bitmap: public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) { int width = bm.getWidth(); int height = bm.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // create a matrix for the manipulation Matrix matrix = new Matrix(); // resize the bit map matrix.postScale(scaleWidth, scaleHeight); // recreate … Read more

Make a SurfaceView larger than the screen (Fitting a camera preview to a SurfaceView larger than the display)

First, remove source of crashes: startPreviewCamera called in onResume. Camera preview shall be started in SurfaceHolder.Callback methods. Then you should know that you can set preview size only to sizes reported by Camera.Parameters.getSupportedPreviewSizes. And these sizes will most likely be smaller or equal to device’s screen size. Then you simply call Camera.Parameters p = camera.getParameters(); … Read more

Fitting a camera preview to a SurfaceView larger than the display

Ok, I know this is very late as an answer but it is possible. Below is code from the Android SDK sample. To see the rest of the code to implement this download the android sdk samples and go to Samples/android-10(one I used, could try whichever you want to target)/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.java class PreviewSurface extends ViewGroup implements … Read more

Minimize Android GLSurfaceView lag

Great question. Quick bit of background for anyone else reading this: The goal here is to minimize the display latency, i.e. the time between when the app renders a frame and when the display panel lights up the pixels. If you’re just throwing content at the screen, it doesn’t matter, because the user can’t tell … Read more