从code将方向为纵向 [英] Set the orientation to portrait from code

查看:139
本文介绍了从code将方向为纵向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 的android:screenOrientation =画像

但是,它可以设置从code的方向?

例如设置活动全屏可无论是从清单,并从code this.getWindow()setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN)来完成。


解决方案

  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

I know I can limit the orientation from the manifest file. Like this

android:screenOrientation="portrait"

But is it possible to set the orientation from code ?

for example setting the activity to full screen can be done both from manifest and from code this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

解决方案

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

这篇关于从code将方向为纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆