Locking Activity Orientation: Android Programming @DrBFraser
Locking Activity Orientation: Android Programming  @DrBFraser
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.
Locking Activity Orientation: Android ProgrammingJUnit 4 with IntelliJ: A quick introductionGit Overview: Git & EclipseEditText and TextView: Android ProgrammingC Makefile Project in Eclipse under LinuxMutex Synchronization in Linux with PthreadsIntroduction to JUnit 5C++ File Input / OutputDeserializing JSON: GSON and JavaCreating a Repository: Git & EclipseProject Spartan: SFU Embedded CosplayJUnit 5 testing in Android Studio: Android Programming
Brian Fraser |

Locking Activity Orientation: Android Programming

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER