Open In App

Screen Orientations in Android with Examples

Screen Orientation, also known as screen rotation, is the attribute of activity element in android. When screen orientation change from one state to other, it is also known as configuration change.

States of Screen orientation
There are various possible screen orientation states for any android application, such as:



The initial orientation of the Screen has to be defined in the AndroidManifest.xml file.

Syntax:






<activity android:name="package_name.Your_ActivityName"  
    android:screenOrientation="orientation_type">  
</activity>  

Example:

    android:screenOrientation="orientation_type">

How to change Screen orientation?
Here is an example of an Android application that changes screen orientation for Landscape and Portrait mode.

We will create two activities of different screen orientation.

Step-by-Step demonstration:


Article Tags :