I am building a game in LibGDX and the game screen orientation is in landscape. I want it to stay in landscape but I still want the user to be able to flip the device onto the other side and the screen will rotate with it. My application refuses to do that and I don't know what to do to fix that. I tried turning on my accelerometer and compass (wasn't expecting anything from compass) but nothing changed. Any ideas?
2 Answers
It defaults to locked on "landscape" mode in a libGDX project. You need to go into your "AndroidManifest.xml" and change android:screenOrientation="landscape" too android:screenOrientation="sensorLandscape"
There are more options - http://developer.android.com/guide/topics/manifest/activity-element.html#screen Just replace "sensorLandScape" with the one you want.
-
1\$\begingroup\$ But I don't want it to switch to portrait but I do want it to switch sides. So if you have your device on one side the screen will stay the same but if want it on another side BUT still landscape it will switch to the other side. \$\endgroup\$ Commented Mar 31, 2014 at 20:16
-
\$\begingroup\$ OOO my bad, add "reverseLandscape" I think \$\endgroup\$– KrtkoCommented Mar 31, 2014 at 20:17
-
1\$\begingroup\$ just FYI, developer.android.com/guide/topics/manifest/… \$\endgroup\$– KrtkoCommented Mar 31, 2014 at 20:19
-
4\$\begingroup\$ reading the docs there, i think you need "sensorLandscape" \$\endgroup\$– KrtkoCommented Mar 31, 2014 at 20:20
-
I know this old, but for the users who come here for an answer, all you need to do is in the "AndroidManifest.xml" file. Where it has a tag you will need to place a android:screenOrientation="sensor" to track its orientation from landscape to portrait and vice versa