【问题标题】:How to run camera only in portrait mode如何仅在纵向模式下运行相机
【发布时间】:2013-01-16 15:33:40
【问题描述】:

我想“仅以纵向模式”运行相机。我在 AndroidManifest 中将 screenOrientation 设置为纵向,但是在拍摄照片时它仍然将方向更改为横向。如何强制它仅在纵向模式下运行。 (仅导致三星 Galaxy s3 和注释 2)

【问题讨论】:

    标签: android camera orientation


    【解决方案1】:

    试着把它放在你的 Activity 的 OnCreate 中

        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD){
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }
    

    【讨论】:

      【解决方案2】:

      解决方案是在 androidmanifest 中进行了简单的修改。将 configChanges 属性添加到活动属性。

      <activity android:name="com.x.yactivity" android:screenOrientation="portrait" android:configChanges="orientation"/>
      

      就是这样。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-06-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多