1
每當我在風景模式下使用相機進行縱向模式時,我爲縱向和橫向模式準備了兩種不同的佈局。在風景模式下使用相機以縱向模式進行預覽
像仍然我在縱向模式下預覽無論我使用的相機在風景或肖像模式,但一旦我刪除此行:mCamera.setDisplayOrientation(90);我得到預覽在風景模式下,無論是我在橫向或縱向模式下使用相機
PreviewSurface.java:-
public class PreviewSurface extends SurfaceView implements
SurfaceHolder.Callback {
public static final String LOG_TAG = "CameraPreview";
private SurfaceHolder mSurfaceHolder;
private Camera mCamera;
// Constructor that obtains context and camera
@SuppressWarnings("deprecation")
public PreviewSurface(Context context, Camera camera) {
super(context);
this.mCamera = camera;
this.mSurfaceHolder = this.getHolder();
this.mSurfaceHolder.addCallback(this);
this.mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
this.mSurfaceHolder.setFixedSize(100, 100);
}
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
try {
mCamera.setPreviewDisplay(surfaceHolder);
mCamera.startPreview();
} catch (IOException e) {
// left blank for now
}
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
mCamera.stopPreview();
mCamera.release();
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int format,
int width, int height) {
// start preview with new settings
try {
mCamera.setDisplayOrientation(90);
mCamera.setPreviewDisplay(surfaceHolder);
mCamera.startPreview();
} catch (Exception e) {
// intentionally left blank for a test
}
}
確定但不知道在哪裏以及如何?我必須使用這 – Sun
這不是很好,但不是一個問題,我可以理解你的挫敗感 – Android