Android-studio – Screen orientation in editor in Android Studio

android-studiolandscapeorientationrotation

In android studio, when run, my program is displayed in landscape mode and works perfectly well. However, when viewing the xml design, the virtual device is displayed in portrait mode. How do I display the xml in landscape mode?

Best Answer

Short Cut

Ctrl+F11 Switch layout orientation portrait/landscape backwards [AVD]

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.

You can add

  android:screenOrientation="landscape"

Your screen will always display in Landscape mode, when you rotate your device, no changes will apply for the current activity.

Like

 <activity
        android:name=".ActivityName"
        android:label="@string/app_name"
        android:screenOrientation="landscape" />

Please check official Guideline:
https://developer.android.com/guide/topics/manifest/activity-element.html#screen