如何禁用横向模式?
How to disable landscape mode?
在我的应用程序中,我在 viewPager 中有 Fragment,我知道如何从清单和 java 中禁用景观,例如:
android:configChanges="orientation"
android:screenOrientation="portrait"
////////////////////////////////
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
(setContent.....)
但是,如果我将我的设备置于横向模式,然后运行应用程序,应用程序将以横向模式加载,而 portarti 模式将无法正常工作。这是为什么?
好吧,我想通了:
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
我忘了删除这一行
在 AndroidManifest.xml 文件中添加这个
android:screenOrientation="portrait"
参加所有活动!!就这些了!!
android:screenOrientation="landscape"
是一侧风景
android:screenOrientation="sensorLandscape"
是两边风景
android:screenOrientation="portrait"
是单侧肖像
android:screenOrientation="sensorPortrait"
是双面人像
android:screenOrientation="fullSensor"
是 所有 4 个边
android:screenOrientation="sensor"
是 一面风景和一面波特率
在我的应用程序中,我在 viewPager 中有 Fragment,我知道如何从清单和 java 中禁用景观,例如:
android:configChanges="orientation"
android:screenOrientation="portrait"
////////////////////////////////
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
(setContent.....)
但是,如果我将我的设备置于横向模式,然后运行应用程序,应用程序将以横向模式加载,而 portarti 模式将无法正常工作。这是为什么?
好吧,我想通了:
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
我忘了删除这一行
在 AndroidManifest.xml 文件中添加这个 android:screenOrientation="portrait"
参加所有活动!!就这些了!!
android:screenOrientation="landscape"
是一侧风景
android:screenOrientation="sensorLandscape"
是两边风景
android:screenOrientation="portrait"
是单侧肖像
android:screenOrientation="sensorPortrait"
是双面人像
android:screenOrientation="fullSensor"
是 所有 4 个边
android:screenOrientation="sensor"
是 一面风景和一面波特率