Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
If you want a fixed horizontal and vertical screen activity, set the following
Set in AndroidManifest.xml:
android: screenOrientation = "portrait" is always displayed in a vertical screen
android: screenOrientation = "landscape" is always displayed in landscape
<activity android:name=".MainActivity" android:screenOrientation="portrait">// android:screenOrientation="landscape" </activity>
In an Activity:
Activity.this.setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); display to portrait
Activity.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);以横屏显示