title: Camera stretched view in android?
body: <p>I use the surface view for showing my customized camera , but view of camera is looking stretched compare to original camera but it was recorded properly. </p>
  
  <p>How can i resolve that problem ?</p>
  
  <p>I use the following code,</p>
  
  <pre><code>public class CamcorderView extends SurfaceView implements
          SurfaceHolder.Callback {
  
      MediaRecorder recorder;
      SurfaceHolder holder;
      String outputFile = "/sdcard/greVat.mp4";
      Context c;
  
      public CamcorderView(Context context, AttributeSet attrs) {
          super(context, attrs);
          c=context;
          holder = getHolder();
          holder.addCallback(this);
          holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  
          recorder = new MediaRecorder();
          recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
          recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
          recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
          recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
          recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
      }
  
      public void surfaceCreated(SurfaceHolder holder) {
          recorder.setOutputFile(path);
          recorder.setPreviewDisplay(holder.getSurface());
          if (recorder != null) {
              try {
                  recorder.prepare();
              } catch (IllegalStateException e) {
                  Log.e("IllegalStateException", e.toString());
              } catch (IOException e) {
                  Log.e("IOException", e.toString());
              }
          }
      }
      public Surface getSurface()
      {
          return holder.getSurface();
      }
      public void surfaceChanged(SurfaceHolder holder, int format, int width,
              int height) {
      }
  
      public void surfaceDestroyed(SurfaceHolder holder) {
          if(recorder!=null)
          {
              recorder.release();
              recorder = null;
          }
      }
  
      public void setOutputFile(String filename)
      {
  
  
          recorder.setOutputFile(path);
      }
      public String deleteVideoPath(){
          return path;
      }
      public String startRecording()
      {   recorder.setOutputFile(path);
  
          recorder.start();
  
          return videoName;
      }
  
      public String stopRecording()
      {
          recorder.stop();
          recorder.release();
          recorder=null;
  
          return path;
      }
      public void release(){
          recorder.release();
          recorder=null;
      }
      public void init(){
          recorder=new MediaRecorder();
      }
  }
  </code></pre>