我正在尝试使用相机预览..
在清单文件中,对于活动,我将screenOrientation设置为景观。另外,android:minSdkVersion设置为10。我使用的是Android 4.0.4版本的摩托罗拉xoom进行测试。
在活动代码中,我看到activity.getWindowManager().getDefaultDisplay().getRotation();的值是“0
此外,info返回0;其中info.orientation是Camera.CameraInfo。
但是,我仍然不确定相机预览是在横向模式下启动的。如何交叉验证在哪种模式下启动相机预览/如何设置相同模式。
发布于 2012-05-20 11:16:29
public void onOrientationChanged(int orientation) {
if (orientation == ORIENTATION_UNKNOWN) return;
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
orientation = (orientation + 45) / 90 * 90;
int rotation = 0;
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation - orientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + orientation) % 360;
}可以使用Camera.Parameters的上述方法并知道方向。请参阅此LINK
https://stackoverflow.com/questions/10670225
复制相似问题