Lock the Orientation of an Android Activity


2011-10-05

Here's how you lock the orientation of an activity in Android:

Open your applications manifest file (usually AndroidManifest.xml) Add android:screenOrientation="portrait" to your activity's attributes (or landscape if you want to lock it in landscape orientation) That's it! An example of an activity element in the manifest would look like this:

<activity android:name=".MyActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait">            
</activity>