I've spent the last two days browsing SO to find answers, unsuccessfully. I'm trying to reproduce a Snapchat-like app.
What I have so far
- A
ViewPager
composed of 3 fragments. - The middle fragment is supposed to display a camera preview, just like Snapchat, on the whole surface (not truly fullscreen but it should cover the entire UI between the status bar and the bottoms buttons)
- I'm able to display either:
- The camera preview, with the correct ratio, but not covering its parent
View
(see picture 1 below) - The camera preview, covering its parent
View
but stretched (wrong ratio)
- The camera preview, with the correct ratio, but not covering its parent
What I need
- Avoid stretching the preview. Possibly, the preview would be cropped on both sides (left and right). See picture 2 below. I guess this is what Snapchat does. Or is there any other way?
What I went through
- http://www.shakedos.com/2015/Aug/26/writing-an-android-portrait-camera-app.html
- Make a SurfaceView larger than the screen (Fitting a camera preview to a SurfaceView larger than the display)
- Android full screen camera - while keeping the camera selected ratio : can't find the whole code
Requirements
- I need to use the Camera API version 1, not version 2.
- Final photos must be taken in 4/3 format, not 16/9.
- Portrait is forced although pictures can be in landscape or portrait
Thank you