How to – Change the Default Screen Orientation – LibGDX

Lately I have been playing around with LibGDX (0.9.9), a cross-platform, open source mobile game development framework. I am generating the cross-platform codes using LibGDX and importing them into Eclipse. The version of Eclipse I am using is the ADT Bundle to quickly start developing apps. It includes the essential Android SDK components and a version of the Eclipse IDE with built-in ADT (Android Developer Tools) to streamline your Android app development. You can download the ADT bundle here.

When I developed my very first and very simple game, and deployed it onto my android device for the first time, I saw that although I had developed the game for portrait orientation  it was being displayed in landscape orientation.

Here is how I solved my problem and how you can set the default orientation of your game:

Open “AndroidManifest.xml” file, found in the root directory of the Android project. Open it with XML Editor as shown below.

Change the value of “android:screenOrientation” to “portrait” (under manifest–>application–>activity) and save the file.
Right-click your android project and select Run As –> Android Application to rebuild your .apk.
Now this apk file should be generated with your new orientation setting, and your game should display in portrait mode.

Hope this helps someone.

Good luck,
Serdar.

Leave a Reply

Your email address will not be published. Required fields are marked *