4

I am trying to achieve a half screen camera preview similar to the one attached in the screen.

I tried nearly all camera preview examples, also tried my own but it either gets the SurfaceView resized to wrap preview sizes (so never half screen size) or it actually fits the half screen but the preview is stretched.

enter image description here

Mo Adel
  • 1,136
  • 1
  • 16
  • 29
  • To be clear: you want the preview to appear on the top half of the screen, but it should include *all* of the camera preview, and preserve the aspect ratio? If so, you probably want a custom FrameLayout, e.g. http://stackoverflow.com/questions/7058507/fixed-aspect-ratio-view – fadden Apr 19 '14 at 15:43
  • @fadden yes exactly top half and fill the top half with the preview but at the same time not stretched for example if you tried "FrontBack" app, that is exactly how i want the top half to be.thanks for pointing me to the link, how would that be implemented using SurfaceView for camera. os should i not use surfaceview – Mo Adel Apr 19 '14 at 21:30
  • 1
    You put the SurfaceView inside the custom FrameLayout in the XML file. You can see an example in Grafika (https://github.com/google/grafika) where I use it for "Play video (SurfaceView)". I have an open "to do" item to fix the aspect ratio on the camera input activities. – fadden Apr 19 '14 at 21:52
  • 2
    FWIW, Grafika's "Show + capture camera" and "Continuous capture" now use the custom layout to show the camera preview with the correct aspect ratio. "Texture from Camera" may also be of interest. – fadden May 07 '14 at 21:33
  • Hi can you please help me to solve problem.I am also getting same problem. preview is stretched. – Alpha Sep 05 '16 at 07:14

0 Answers0