在纵向模式下锁定手机 [英] Locking phone in portrait mode

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

问题描述

我想改变旋转模式在我的应用程序编程。所有我发现讨论是关于具体活动禁止转动。我想锁定整部手机在纵向模式。我如何做到这一点?

I want to change the rotation mode in my application programmatically. All the discussions I found were about disabling rotation in specific Activities. I want to lock the whole phone in portrait mode. How do I accomplish this?

编辑。为了澄清,我要锁定整个手机在内的所有其他应用程序,设置等。不只是我自己的应用程序。

Edit. To clarify, I want to lock the whole phone including all other apps, settings etc. Not just my own app.

推荐答案

以下内容添加到您的活动的onCreate:

Add the following to your Activities onCreate:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

这篇关于在纵向模式下锁定手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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