title: Android: Camera preview doesn't look nice
body: <p>I've written a camera app (activity) that takes a picture, but the preview that shows the live picture of camera doesn't look nice, it's a bit tall, like this :
  <img src="https://i.stack.imgur.com/erQUl.png" alt="enter image description here"></p>
  
  <p>Here is the code for my camera preview :</p>
  
  <pre><code>    public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback
      {
          private SurfaceHolder mHolder ;
          private Camera mCamera; 
          public CameraPreview(Context context , Camera camera)
          {
              super(context) ;
              mCamera = camera ;
  
              mHolder = getHolder();
              mHolder.addCallback(this);
              mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
          }
          public void surfaceCreated(SurfaceHolder holder)
          {
              try
              {
                  mCamera.setPreviewDisplay(holder);
                  mCamera.startPreview();
              }
              catch(IOException e)
              {
                  Log.d(TAG,"Camera Preview Failed!: "+e.getMessage());
              }
          }
          public void surfaceChanged(SurfaceHolder holder , int m , int n , int w)
          {   
          }
          public void surfaceDestroyed(SurfaceHolder holder)
          {           
          }
      }
  
  
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
      &lt;FrameLayout
          android:id="@+id/camera_preview"
          android:layout_width="wrap_content"
          android:layout_height="0dip"
          android:layout_weight="0.86" /&gt;
  
      &lt;Button
          android:id="@+id/button_capture"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginBottom="16dp"
          android:gravity="center"
          android:onClick="capture"
          android:text="Capture" /&gt;
  
      &lt;Button
          android:id="@+id/button_accept"
          android:layout_width="115dp"
          android:layout_height="wrap_content"
          android:text="Accept"
          android:visibility="gone"
          android:onClick = "accept" /&gt;
  
      &lt;Button
          android:id="@+id/button_retake"
          android:layout_width="107dp"
          android:layout_height="wrap_content"
          android:text="Retake" 
          android:visibility="gone"
          android:onClick = "retake"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>