Android:纵向模式下的相机预览方向

标签 android camera rotation orientation portrait

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

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

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

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

最佳答案

强制纵向:

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

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

注意:setDisplayOrientation 是在 API Level 8 中添加的

关于Android:纵向模式下的相机预览方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10660598/

相关文章:

iPhone屏幕旋转: Can I enforce 90 degree rotations?

iphone - 强制 autoresizingMask 应用于 UIView

java - for each 里面一个 for each - Java

android.support.constraint.ConstraintLayout 无法转换为 android.widget.RelativeLayout

javascript - 传递并返回来自 javascript 和 android 的值,并用作手机间隙插件

ios - UIImagePickerController didFinishPickingMediaWithInfo

android - 未调用相机 onPreviewFrame

android - 显示来自特定 channel 的 Youtube 视频

来自相机的 android 位图只是缩略图大小?

Chrome 中的 CSS3 过渡变换 rotateX