Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screen orientation in editor in Android Studio

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?

like image 900
gavin Avatar asked Oct 14 '25 03:10

gavin


2 Answers

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

like image 80
IntelliJ Amiya Avatar answered Oct 18 '25 07:10

IntelliJ Amiya


Click that button next to "Nexus 5".

enter image description here

like image 38
Jagoan Neon Avatar answered Oct 18 '25 07:10

Jagoan Neon