trainingtrains Logo

91-9990449935

 0120-4256464

Android Screen Orientation Example

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:

The common values for screenOrientation attribute are as follows:

ValueDescription
unspecifiedIt is the default value. In such case, system chooses the orientation.
portraittaller not wider
landscapewider not taller
sensororientation is determined by the device orientation sensor.

Android landscape mode screen orientation example

activity_main.xml

File: activity_main.xml

Activity class

File: MainActivity.java

AndroidManifest.xml

File: AndroidManifest.xml


Output:

android screen orientation example output 1