1

I have two screens: Menu and Game. How can I set portrait mode for Menu and landscape mode for Game in libGdx?

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

2 Answers2

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Lucas B
  • 338
  • 4
  • 14
  • 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