Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android View with 'hole' in it

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?

like image 925
fluffyemily Avatar asked Oct 15 '25 23:10

fluffyemily


1 Answers

Use SurfaceView.

"the SurfaceView punches a hole in its window to allow its surface to be displayed"

like image 80
ata Avatar answered Oct 18 '25 14:10

ata



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!