Android: Camera preview orientation in portrait mode

前端 未结 2 1252
隐瞒了意图╮
隐瞒了意图╮ 2020-12-09 10:25

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

The app is always in portrait mode (landscape mode is disabled). The camera previ

2条回答
  •  悲&欢浪女
    2020-12-09 10:28

    To force portrait orientation:

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

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

    Note: setDisplayOrientation was added in API Level 8

提交回复
热议问题