title: android camera preview wrong aspect ratio
body: <p>i created a camera app based on tutorial. the preview class i use is from api-Demos "CameraPreview". I added a modification from <a href="https://stackoverflow.com/questions/3841122/android-camera-preview-is-sideways/5110406#5110406">here</a> (preview was always rotated by 90°). So this is how i set preview size:</p>
  
  <pre><code>    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
      // Now that the size is known, set up the camera parameters and begin
      // the preview.
      Camera.Parameters parameters = mCamera.getParameters();
      Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  
      if (display.getRotation() == Surface.ROTATION_0) {
          parameters.setPreviewSize(mPreviewSize.height, mPreviewSize.width);
          mCamera.setDisplayOrientation(90);
      }
  
      if (display.getRotation() == Surface.ROTATION_90) {
          parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
      }
  
      if (display.getRotation() == Surface.ROTATION_180) {
          parameters.setPreviewSize(mPreviewSize.height, mPreviewSize.width);
      }
  
      if (display.getRotation() == Surface.ROTATION_270) {
          parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
          mCamera.setDisplayOrientation(180);
      }
      parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
  
      requestLayout();
  
      mCamera.setParameters(parameters);
      mCamera.startPreview();
  }
  </code></pre>
  
  <p>But the Preview is displayed with wrong aspect ratio. Is it because of the code above or probably because of the layout i use?:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;Button
      android:id="@+id/button_capture"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true" 
      android:text="@string/capture" /&gt;
  
  &lt;FrameLayout
      android:id="@+id/camera_preview"
      android:layout_width="100dp"
      android:layout_height="match_parent"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>So how to get the correct aspect ratio? Thanks in advance.</p>
  
  <p>P.S. i read the answer from: <a href="https://stackoverflow.com/questions/12751016/android-camera-preview-look-strange">Android camera preview look strange</a>
  But this isn't working  for me.</p>