Android:纵向模式下的相机预览方向 [英] Android: Camera preview orientation in portrait mode

查看:22
本文介绍了Android:纵向模式下的相机预览方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用相机仅显示预览(不拍照或录制视频).

I'm using the camera to show preview only (not to take pictures or record videos).

应用始终处于纵向模式(横向模式已禁用).相机预览总是逆时针旋转 90 度,我无法更改它(无论是 setDisplayOrientation 还是 p.set("orientation", "portrait" )p.set("rotation", 90) ).

The app is always in portrait mode (landscape mode is disabled). The camera preview is always rotated 90 degrees ccw and I can't change it (neither with setDisplayOrientation nor with p.set("orientation", "portrait" ) and p.set("rotation", 90) ).

预览总是像这样旋转还是取决于设备?如果在纵向模式下总是这样,我可以在之后旋转图像.

Is the preview ALWAYS rotated like this or is it device dependent? If it was always like this in portrait mode, I could just rotate the image afterwards.

或者有没有办法正确设置相机?我已经阅读了很多关于此的主题,但没有任何答案对我有用(Galaxy s2,Android v2.3)

Or is there a way to set up the camera correctly? I've read a lot of threads about this but no answer worked for me (Galaxy s2, Android v2.3)

推荐答案

强制纵向:

在您的 AndroidManifest.xml 中设置 android:screenOrientation="portrait" 并在调用 之前调用 camera.setDisplayOrientation(90);>camera.startPreview();

set android:screenOrientation="portrait" in your AndroidManifest.xml and call camera.setDisplayOrientation(90); before calling camera.startPreview();

我没有在 GS2 上测试过,但它适用于我测试过的每部手机.

I have not tested on the GS2 but it works on every phone I have tested on.

注意:在 API 级别 8

这篇关于Android:纵向模式下的相机预览方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆