diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a5b294e..a1aecd3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,9 @@ + + sizes = params.getSupportedPictureSizes(); Camera.Size mSize = null; @@ -34,18 +35,18 @@ public void surfaceCreated(@NonNull SurfaceHolder surfaceHolder) { //change orientation of camera if(this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE){ params.set("orientation","portrait"); - camera.setDisplayOrientation(90); + mCamera.setDisplayOrientation(90); params.setRotation(90); }else { params.set("orientation","landscape"); - camera.setDisplayOrientation(0); + mCamera.setDisplayOrientation(0); params.setRotation(0); } params.setPictureSize(mSize.width,mSize.height); - camera.setParameters(params); + mCamera.setParameters(params); try { - camera.setPreviewDisplay(holder); - camera.startPreview(); + mCamera.setPreviewDisplay(mSurfaceHolder); + mCamera.startPreview(); }catch (IOException e){ e.printStackTrace(); } @@ -53,13 +54,13 @@ public void surfaceCreated(@NonNull SurfaceHolder surfaceHolder) { } @Override - public void surfaceChanged(@NonNull SurfaceHolder surfaceHolder, int i, int i1, int i2) { + public void surfaceChanged(@NonNull SurfaceHolder surfaceHolder, int format, int width, int height) { } @Override public void surfaceDestroyed(@NonNull SurfaceHolder surfaceHolder) { - camera.stopPreview(); - camera.release(); + mCamera.stopPreview(); + mCamera.release(); } } diff --git a/app/src/main/res/layout/fragment_photo.xml b/app/src/main/res/layout/fragment_photo.xml index aac2a95..372053b 100644 --- a/app/src/main/res/layout/fragment_photo.xml +++ b/app/src/main/res/layout/fragment_photo.xml @@ -1,20 +1,27 @@ - + + - + android:background="#e7e7e7" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true"> - - + + + + + + + + + + android:layout_height="300dp" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true" + android:gravity="center" + android:background="#fff">