I have a TextureView with a fixed width and height and I want to show a camera preview inside of it. I need to crop the camera preview so that it doesn\'t look stretched ins
I have just made a working app where I needed to show a preview with x2 of the actual input without getting a pixelated look. Ie. I needed to show the center part of a 1280x720 live preview in a 640x360 TextureView.
Here is what I did.
Set the camera preview to x2 resolution of what I needed:
params.setPreviewSize(1280, 720);
And then scale the texture view accordingly:
this.captureView.setScaleX(2f);
this.captureView.setScaleY(2f);
This runs without any hiccups on small devices.