简体   繁体   中英

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.

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!"

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..

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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