项目需求 要求应用必须为竖屏 可在AndroidManifest.xml的activity节点中设置
android:screenOrientation="portrait"
android:name="com.***.***Activity" android:label="@string/****" android:screenOrientation="portrait">
横屏: 更改为 android:screenOrientation="landscape"
如需要在代码中设置
强制竖屏: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
强制横屏 :
if(getRequestedOrientation()!=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}