title: Square SurfaceView(aspect ratio of 1:1) for a custom camera implementation (Like Instagram)
body: <p>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 </p>
  
  <pre><code>@Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
      setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
  }
  </code></pre>
  
  <p>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.</p>