title: Fix Android Camera app aspect ratio and rotation
body: <p>How it looks:
  <a href="http://i41.tinypic.com/30278m1.png">http://i41.tinypic.com/30278m1.png</a></p>
  
  <p>It looks like in the pic ,I want it to have a correct aspect ratio with correct rotaion</p>
  
  <p>Take a look the code please , how can I fix it ?</p>
  
  <p>This is my code:</p>
  
  <pre><code>    public class MainActivity extends Activity implements SurfaceHolder.Callback {
  
  Camera mCamera;
  SurfaceView mPreview; 
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mPreview = (SurfaceView)findViewById(R.id.preview);
      mPreview.getHolder().addCallback(this);
      mPreview.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
      mCamera = Camera.open();
  }   
  @Override
  public void onPause() {
      super.onPause();
      mCamera.stopPreview();
  }    
  @Override
  public void onDestroy() {
      super.onDestroy();
      mCamera.release();
  }
  @Override
  public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
      Camera.Parameters params = mCamera.getParameters();
      List&lt;Camera.Size&gt; sizes = params.getSupportedPreviewSizes();
      Camera.Size selected = sizes.get(0);
      params.setPreviewSize(selected.width,selected.height);
      mCamera.setParameters(params);
      mCamera.startPreview();
  }
  @Override
  public void surfaceCreated(SurfaceHolder holder) {
      try {
          mCamera.setPreviewDisplay(mPreview.getHolder());
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  @Override
  public void surfaceDestroyed(SurfaceHolder holder) {
      Log.i("PREVIEW","surfaceDestroyed");
  }
  }
  </code></pre>