How is application orientation (landscape or portrait) locked?

前端 未结 4 1102
春和景丽
春和景丽 2020-12-09 05:18

I have tried to freeze orientation using:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Although the display stays in

4条回答
  •  不思量自难忘°
    2020-12-09 05:42

    First, don't use setRequestedOrientation() if you can avoid it. Use the android:screenOrientation attribute in your manifest element instead.

    Second, you will also need android:configChanges="keyboardHidden|orientation" in your manifest element to prevent the destroy/recreate cycle.

提交回复
热议问题