I have an application where the photo preview size is smaller than the phone screen. I read a lot of posts / ideas on how to fix this, but my preview is still distorted.
Ideally, I could save the preview area as it is, and “stretch and re-center” the preview so that the edges of the photo would not appear on the screen.
From what I can say, I get all the correct values for the height and width of the photo and the height and width of the photo, but I'm not sure where and how I can adjust the stretch factor. Right now, a 640x480 photo (or any other size) is added to the smaller preview area.
Here is the code I'm using:
class Preview extends SurfaceView implements SurfaceHolder.Callback { SurfaceHolder mHolder; public Camera camera; boolean writingFile = false; Size theBiggest=null; Size screenSize=null; Float cameraRatio=null; Preview(Context context) { super(context);
Here is my layout xml file
<FrameLayout android:layout_weight="1" android:id="@+id/preview" android:fitsSystemWindows="true" android:layout_height="0dp" android:layout_width="wrap_content"> </FrameLayout> <Button android:text="Take Photo" android:id="@+id/buttonClick" android:layout_height="wrap_content" android:layout_width="200dp" android:layout_gravity="center" android:textSize="12sp"> </Button>
source share