How to disable landscape mode?

拜拜、爱过 提交于 2019-12-08 11:00:02

问题


i'n my application i have Fragment's in a viewPager i know how to disable the landscape from manifest and from java like :

            android:configChanges="orientation"
           android:screenOrientation="portrait"

////////////////////////////////
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    (setContent.....)

but if i hold my device in landscape mode and then i running the application the application load in landscape and the portarti mode not working. why is that?

Ok i figure it out my bad:

getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);

I forget to delete this line


回答1:


In the AndroidManifest.xml file add this android:screenOrientation="portrait"

to all the activities !! Thats all !!




回答2:


android:screenOrientation="landscape" is one side landscpe

android:screenOrientation="sensorLandscape" is both side landscape

android:screenOrientation="portrait" is one side portrait

android:screenOrientation="sensorPortrait" is both side portrait

android:screenOrientation="fullSensor" is all 4 sides

android:screenOrientation="sensor" is one side landscape and one side potrate



来源:https://stackoverflow.com/questions/27730827/how-to-disable-landscape-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!