在AAndroidManifest.xml 中的<activity> </activity>设置屏幕方向为竖屏:
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation" >
Android开发文档中,设置预览方向的代码如下:
http://developer.android.com/intl/zh-cn/training/camera/cameradirect.html
public static void setCameraDisplayOrientation (Activity activity, int cameraId, android.hardware.Camera camera) {
android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo (cameraId , info);
int rotation = activity.getWindowManager ().getDefaultDisplay ().getRotation ();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;