Setting the orientation for only 1 fragment in my activity while the rest is in portrait

后端 未结 8 1065
难免孤独
难免孤独 2020-12-05 01:52

My app needs to be in portrait mode so I set it in the manifest by:

android:screenOrientation=\"portrait\"

But I just recently added anothe

8条回答
  •  有刺的猬
    2020-12-05 02:28

    First Fragment:

    @Override
        public void onResume() {
            super.onResume();
            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    
        }
    

    Second Fragment:

         @Override
            public void onResume() {
                super.onResume();
     getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
       }
    

提交回复
热议问题