Uploaded February 2013 | Updated November 2026, 3 hours ago
Tutorial on locking the orientation of your Android activities.
Controlling Screen Orientation
==============================
Normally when the phone is rotated between portrait and landscape layout,
Android will destroy and recreate the current activity in the new layout.
We want to:
1. Not be destroyed in the middle of our game.
2. Force it to be landscape
Steps
-----
1. Open AndroidManifest.xml
2. Add to {activity... } the following:
(NOTE: Cannot put the less-than/greater-than in a YouTube description; the {..} should be the start/end of the activity XML tag.)
android:screenOrientation="landscape"
android:configChanges="keyboard|orientation|keyboardHidden|screenSize"
Options: "landscape" | "portrait" |"reverseLandscape" | "reversePortrait"
Example
-------
Full exapmle of the {activity... part
{activity
android:name="ca.your.package.YourActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|orientation|keyboardHidden|screenSize"
}
{intent-filter}
{action android:name="android.intent.action.MAIN" /}
{category android:name="android.intent.category.LAUNCHER" /}
{/intent-filter}
{/activity}
Notes
-----
- You can apply these orientation attributes to some or all of your Activities.
Tutorial on locking the orientation of your Android activities.
Controlling Screen Orientation
==============================
Normally when the phone is rotated between portrait and landscape layout,
Android will destroy and recreate the current activity in the new layout.
We want to:
1. Not be destroyed in the middle of our game.
2. Force it to be landscape
Steps
-----
1. Open AndroidManifest.xml
2. Add to {activity... } the following:
(NOTE: Cannot put the less-than/greater-than in a YouTube description; the {..} should be the start/end of the activity XML tag.)
android:screenOrientation="landscape"
android:configChanges="keyboard|orientation|keyboardHidden|screenSize"
Options: "landscape" | "portrait" |"reverseLandscape" | "reversePortrait"
Example
-------
Full exapmle of the {activity... part
{activity
android:name="ca.your.package.YourActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|orientation|keyboardHidden|screenSize"
}
{intent-filter}
{action android:name="android.intent.action.MAIN" /}
{category android:name="android.intent.category.LAUNCHER" /}
{/intent-filter}
{/activity}
Notes
-----
- You can apply these orientation attributes to some or all of your Activities.










