How to lock an Android apps orientation in Android Studio

Oscar de la Hera Gomez
Two flowers that represent Android and Android Studio side by side. Beneath it sits the text "Lock App Orientation."

A step by step guide for limiting an Android device's orientation to landscape, portrait or another orientation within an app.

Step One: Open the Android Manifest

A screenshot of Android Studio showing the AndroidManifest.xml file for our open source starter project.

In the project, Open the AndroidManifest.xml file.

Step Two: Lock the Orientation of the Activity

A screenshot of Android Studio showing the AndroidManifest.xml file with a highlight on the orientations that can be set.

Under each activity set the desired orientation using code similar to that below.

android:screenOrientation='portrait'

Step Three: Test

A screenshot of Android Studio showing that the design remains portrait even if the device is rotated to Landscape orientation.

Run the app and confirm that the app is locked to the orientation.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details