简体   繁体   English

屏幕方向被强制设置为纵向,但倾斜时活动仍将旋转为横向! 如何强制人像模式?

[英]Screen orientation forced to portrait, but still, the activities will rotate to landscape when tilted!! How to force portrait mode?

I've searched stackoverflow for this and didn't get any solution to what I am looking for. 我已经在stackoverflow上搜索了此内容,但没有找到我想要的任何解决方案。

In my manifest file I am writing the following line for each activity 在清单文件中,我为每个活动编写了以下行

android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden"

But still, all the activities rotate to landscape on tilting the phone. 但仍然,所有活动都会在倾斜手机时旋转到横向。

How can I solve this issue ? 我该如何解决这个问题?

"Once upon a time I was a confident developer in C/C++,iOS,Java,Javascript,C# but thank you android! now I can't even look eye to eye in mirror!" “从前,我是C / C ++,iOS,Java,Javascript,C#的自信开发人员,但感谢android!现在我什至无法与镜子并驾齐驱!”

May be this will help 也许这会有所帮助

In your manifest file after your main activity write below line 在您的主要活动之后的清单文件中,在下面的行中编写

 android:screenOrientation="portrait"

Or in your coding after setContentView() add this line.. 或在setContentView()之后的代码中添加此行。

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

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

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