I am trying to build a custom camera view which fills the whole screen by stretching the preview while maintaining the aspect ratio and having the parts outside the screen cropped. I have been unable to get the surface view which the camera uses to stretch larger than the screen size. I can get it to be smaller than the screen, or have it stretched to match the screen exactly which ruins the aspect ratio. How do I go about getting the camera to fill the screen without losing the aspect ratio?
Related
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)
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
I am using libgdx to create a game for android. If I want to set the background as an image that fills up the whole screen, how can I keep the aspect ratio of the image? I don't want remaining blank space or letter boxing, but if you set the image size as the whole screen, it is going to stretch on some devices and it will look distorted...
Developing an app for Android and I'm required to have a fullscreen image rotate (spin around infinitely, pivoted at the centre of the screen) in the background.
I have tried rotating the ImageView using RotateAnimation which works well, except the image is cropped to the size of the parent view.
I have also tried expanding the parent view to a set size (750dp) but it doesn't work well across all the different screen sizes.
Does anyone know of an easy way to implement this, which would involve scaling to uniformly fit the screen size?
Cheers,
Dylan
Screenshot of the image:
I'm creating an Android application which adds frames to images (Think those things at the beach that you stick your head in...), but I want the image to show on top of the surface view holding the camera feed so that the user can position the subject of the photo.
The problem I'm having is that the camera feed (the surface view) is showing either side of the image. I want to re-size the surface view to fit the image. The size of the image may vary.
I think you like to have some overlay on top of surface view - this is achieved with frame layout like this:
http://javaocr.svn.sourceforge.net/viewvc/javaocr/trunk/demos/sampler/res/layout/main.xml?revision=229&view=markup
You can place everything but other surface view in the overlay
If I have a surface view and in that surface view I place a 50x50 image at the coordinates of 0 and 0 and then put that surface view inside of a relative layout and place it at the top left hand corner what will happen?
What will happen if I place that surface view at another position?
Also, since I am programming with a 480x800 device as my core emulator, what will happen if I used a device that is smaller?
Basically, how can I create something in a surface view and have the items in it increase or decrease in size proportionally to the device size?