Maggie
Maggie

Reputation: 8081

android, use camera as a background for an activity

I have a request that background for my activity must be "transparent", ie. background of an activity should be camera's current view. What is the easiest way to implemet this? I have all the activities already implemented, with all the logic already implemented. Ideally, solution wouldn't include a lot of modification of an existing code.

Upvotes: 0

Views: 1162

Answers (1)

Peter Knego
Peter Knego

Reputation: 80340

Normally this is done with SurfaceView. Use it via camera.setPreviewDisplay(surfaceView)

To use it in your app, the simplest way would be to use FrameLayout as a top layout of your Activity and then put SurfaceView any you current top layout inside it.

`FrameLayout`
    `SurfaceView`
    `yourExistingLayout`

Of course your existing layout must be transparent to see the underlying SurfaceView. Note also that this alpha blending takes a lot of processor power so it will eat battery.

Upvotes: 2

Related Questions