Android-- set a fixed horizontal and vertical screen

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.
This link: https://blog.csdn.net/weixin_37758967/article/details/87624021

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);以横屏显示
 

Guess you like

Origin blog.csdn.net/weixin_37758967/article/details/87624021