How to lock fragment orientation without locking activity orientation?

后端 未结 2 500
长发绾君心
长发绾君心 2021-02-07 08:38

I have a specific use case where I want a fragment to be locked in portrait mode, but still rotate the activity (and/or other fragments visible in the same activity). Is it poss

2条回答
  •  悲哀的现实
    2021-02-07 09:07

    Its may be little late for the reply, but as i can see you haven't found a solution, You can try doing this, Whenever you are calling your fragment from your activity, add below code before it

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
    

    and for all other/default Fragment

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    

    Hope i helped

提交回复
热议问题