1.AndroidManifest.xml:
<activity>
android:screenOrientation="portrait"
。。。
2.xx.java:
<activity>
android:screenOrientation="portrait"
//如果是竖排,则改为横排;反之然
if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}