简体   繁体   English

如何在Android中禁用屏幕旋转?

[英]How to disable screen rotation in Android?

I'm trying to make it so the screen can't rotate when you turn it because it screws up some of the graphics. 我正在尝试制作它,以使屏幕在旋转时不会旋转,因为它会拧紧一些图形。 Is there a way to do this? 有没有办法做到这一点?

Just Add android:screenOrientation="portrait" to your <activity> tag in the manifest to disable orientation. 只需将android:screenOrientation="portrait"添加到清单中的<activity>标记即可禁用方向。

You can also try to stop the activity from recreating itself when rotating by adding this android:configChanges="orientation|screenSize|keyboardHidden" to your <activity> tag. 您也可以尝试通过在<activity>标记中添加android:configChanges="orientation|screenSize|keyboardHidden"来阻止旋转时重新创建<activity>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM