Set the orientation to portrait from code

不想你离开。 提交于 2019-12-20 03:19:50

问题


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


回答1:


setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);



回答2:


Activity. setRequestedOrientation(..)


来源:https://stackoverflow.com/questions/8035453/set-the-orientation-to-portrait-from-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!