I am working on an app at the moment. The client requires the camera preview to be a square. I tried this by overriding onmeasure in the surfaceview implementation and setting
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
}
This does not work too well, as the preview is stretched or compressed. Can anyone guide me as to what needs to be done to get a 1:1 aspect ratio. I have read about getting supported preview sizes but none of them are in the required 1:1 aspect ratio.