Lock screen orientation when targeting Android API 27 with a non-opaque activity

前端 未结 9 739
囚心锁ツ
囚心锁ツ 2020-12-13 09:30

I have an activity that has android:windowIsTranslucent set to true and android:windowBackground set to a translucent background. I ju

9条回答
  •  情歌与酒
    2020-12-13 09:38

    So what I did was remove any screenOrientation property from manifest and add it to my BaseActivity (from which all my activities extend), this code

     if(!(this instanceof TranslucentActivity)){
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    

    The TranslucentActivity will have the orientation from the Activity behind.

提交回复
热议问题