SCREEN_ORIENTATION_LANDSCAPE upside down - Why?

后端 未结 4 837
眼角桃花
眼角桃花 2021-01-11 13:16

I am using the following code to set orientation locking per user preference:

 private void doLock(boolean locked) {
     if (locked) {
       int o = getRes         


        
4条回答
  •  走了就别回头了
    2021-01-11 13:59

    What you are describing is not a bug but rather the expected behavior from Android 2.2 or lower.

    @forgivegod provided a theoretically correct approach, except that for Android 2.2 or lower the screenOrientation.reverseLandscape and screenOrientation.reversePortrait values are not recognized, even if faked (as @forgivegod's code does).

    I bet you are seeing this problem when you rotate the phone clockwise (rotation=3) but not counter-clockwise (rotation=1).

    Try with Android 2.3 or higher and see what happens.

提交回复
热议问题