【问题标题】:Set the orientation to portrait from code从代码中将方向设置为纵向
【发布时间】:2011-11-07 10:53:40
【问题描述】:

我知道我可以从清单文件中限制方向。像这样

android:screenOrientation="portrait"

但是可以通过代码设置方向吗?

例如,可以通过清单和代码 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 将活动设置为全屏

【问题讨论】:

标签: android orientation manifest screen-orientation portrait


【解决方案1】:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

【讨论】:

    【解决方案2】:
    Activity. setRequestedOrientation(..)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-16
      • 1970-01-01
      • 2012-11-16
      相关资源
      最近更新 更多