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);
}

相关文章:

  • 2022-12-23
  • 2021-06-12
  • 2021-11-28
  • 2021-11-19
  • 2021-08-10
  • 2022-12-23
  • 2021-05-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-12-14
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案