How to lock an Android apps orientation in Android Studio

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

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 06/28/2023 at 14:17
Last Updated on 06/28/2023 at 15:03
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.

SubscribeDownload Open Source Kotlin Starter Project

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.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe