Android Learning
HomeBlogAbout

Android Learning

Learn Android development with comprehensive tutorials, guides, and best practices. From beginner to advanced Android programming.

Quick Links

  • Home
  • Blog
  • About
  • Contact
  • Newsletter

Resources

  • Android Developers
  • Kotlin Docs
  • Jetpack Compose

© 2026 Android Learning. All rights reserved.

Privacy PolicyTerms of Service
Back to Blog
March 29, 2016
3 min read
Akshay Raj

Android Screen Orientation

Android Screen Orientation

Akshay Raj

Android development expert

The screenOrientation is the attribute of activity element. The orientation of android activity can be portrait, landscape, sensor, unspecified etc. You need to define it in the AndroidManifest.xml file. For example:
<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait">
Value Description
unspecified It is the default value. In such case, system chooses the orientation.
portrait taller not wider
landscape wider not taller
sensor orientation is determined by the device orientation sensor.
One of the key features of modern smartphones is their ability to switch screen orientation, and Android is no exception. Android supports two screen orientations: portrait and landscape. By default, when you change the display orientation of your Android device, the current activity that is displayed automatically redraws its content in the new orientation. This is because the onCreate() method of the activity is fired whenever there is a change in display orientation.
NOTE: When you change the orientation of your Android device, your current activity is actually destroyed and then recreated.
One of the most common “solutions” to dealing with orientation changes is to not deal with them. You can do this by setting the android:configChanges flag on your Activity in AndroidManifest.xml as shown below:
<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="orientation|screenSize|keyboardHidden" >

Comments

No comments yet.

Enjoyed this article?

Subscribe to our newsletter to get more articles like this delivered to your inbox.