Reputation: 55
I've created a custom camera view for Android. I have overlayed the camera preview with a semi transparent LinearLayout with a TextView and Button. Now I need to punch a 'hole' in the middle of the view so you can see the underlying camera preview clearly . The hole then acts as a frame guideline allowing the user to 'frame' the photo.
I succeeded with the iOS version by creating a view and cutting out a rectangle from the view as demonstrated here. How would I go about doing the same thing for Android?
Upvotes: 4
Views: 3548
Reputation: 9011
Use SurfaceView.
"the SurfaceView punches a hole in its window to allow its surface to be displayed"
Upvotes: 3
Reputation: 2215
This is the code I'm using:
setContentView(mCameraPreview);
addContentView(mOtherView, new LayoutParams
(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
Areas that are transparent in mOtherView will allow the camera preview to show through.
Upvotes: 0
Reputation: 25058
You're going to need to start with the hole and build around it. Layers in Android are additive, there is no way to punch a hole.
Upvotes: 0