How to toggle orientation lock in android?

后端 未结 1 968
一生所求
一生所求 2021-02-07 13:47

I want to create checkbox in my preference Activity that allows user to toggle orientation change.

In similar questions people write only about complete orientation loc

相关标签:
1条回答
  • 2021-02-07 14:09

    I don't understand what is the problem with the setRequestedOrientation.

    The SCREEN_ORIENTATION_SENSOR combine to landscape or portrait seem what you want, no?

    if(....)
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    else if(....)
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    else if(....)
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    
    0 讨论(0)
提交回复
热议问题