Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android force Horizontal (landscape) layout [duplicate]

Tags:

android

layout

I'm pretty close to finished with my first game for Android, and I've come across a problem that's so simple I'm sure I'll feel stupid for not knowing how to solve it, but how can I force the app to stay in a Horizontal layout? Right now, if you turn the phone (emulator) it flips the graphics and squeezes them. I want the game to start horizontally and stay that way regardless of how the user turns the phone.

Thank you.

like image 913
Ben Mc Avatar asked Jan 14 '10 20:01

Ben Mc


People also ask

How do I force horizontal orientation on android?

Open the AndroidManifest. xml and add the following android:screenOrientation="landscape" e.g. Show activity on this post. To do this at the Activity level, in case you want to change it dynamically or allow the user to select the orientation, use setRequestedOrientation in your Activity's onCreate method.

How do I change the layout of landscape in android?

Step 1: Open the base UI layout in DESIGN mode so that you see the actual GUI, such as Buttons, icons, etc. Step 2: Click the icon marked in the below screenshot and, from the menu, select Create Landscape Variation. Then the corresponding Landscape file will be created automatically named as land\xml file name.

How do I change the orientation of android manifest?

The screen orientation attribute is provided by the activity element in the Android Manifest. Xml file. The orientations provided by the activity are Portrait, Landscape, Sensor, Unspecified and so on. To perform a screen orientation activity you define the properties in the Android Manifest.


2 Answers

Open the AndroidManifest.xml and add the following android:screenOrientation="landscape" e.g.

 <activity android:name=".ActivtyName"         android:screenOrientation="landscape"                 > 
like image 68
Ally Avatar answered Sep 19 '22 03:09

Ally


To do this at the Activity level, in case you want to change it dynamically or allow the user to select the orientation, use setRequestedOrientation in your Activity's onCreate method.

this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 

etc...

like image 29
EddieB Avatar answered Sep 20 '22 03:09

EddieB