android, use camera as a background for an activity
I have a request that background for my activi开发者_StackOverflow中文版ty 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.
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.
精彩评论