I have two screens: Menu and Game. How can I set portrait mode for Menu and landscape
mode for Game in libGdx
?
Asked
Active
Viewed 651 times
1

Naveen Tamrakar
- 3,349
- 1
- 19
- 28

SzewskiJanusz
- 13
- 3
2 Answers
1
Setting the android:screenOrientation="portrait"
or android:screenOrientation="landscape"
in Manifest
Android
<activity android:name=".MenuActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" />
<activity android:name=".GameActivity"
android:label="@string/app_name"
android:screenOrientation="landscape" />

Naveen Tamrakar
- 3,349
- 1
- 19
- 28
-
Do have I to keep screens in android module or there is a way to keep it in core module? – SzewskiJanusz Sep 29 '17 at 18:34
-2
Why would you want to do this? Aren't you just better off having one orientation, or auto rotate? Wouldn't you confuse the user by changing orientations?
If you really want this, here is an example for how to set to auto rotate programmatically:
Enable and disable auto rotate programmatically?
For libgdx, there is no api to change screen orientation.
So either go to your XML file and set to auto oriented, or check out that stackoverflow link to change orientation programmatically.
-
There are many apps that go widescreen on certain activities like viewing a movie, or playing a game. While home screens or settings may feel more natural in a one handed usage aka vertical. You answer was pointed without understanding the circumstance or user experience. – Sam Sep 29 '17 at 18:42