Android emulator
screen orientation
Android development
emulator tips
change screen orientation

How to rotate the screen in the Android emulator

Codemia Knowledge Hub ·

Click the rotate-left or rotate-right button on the emulator toolbar. For scripted tests, turn off accelerometer_rotation and set the orientation with adb shell settings put system user_rotation. If the device rotates but the screen does not, the cause is usually Android's rotation lock or the app's own configuration, not the emulator.

Rotating with the emulator controls

In the running emulator window, the rotate buttons on the toolbar simulate turning the device, the same as rotating a physical phone.

For keyboard shortcuts, open the emulator help pane to see the mappings for your setup. They can differ depending on whether the emulator runs embedded in Android Studio or in a separate window, so do not rely on old shortcut assumptions.

These controls only simulate turning the device. They do not override your activity's manifest settings.

Checking that auto-rotate is not locked

If the emulator rotates but the contents do not, auto-rotate may be disabled. Open quick settings inside the emulator and make sure rotation lock is off.

For scripted testing, adb can set the system setting directly:

bash
adb shell settings put system accelerometer_rotation 0
adb shell settings put system user_rotation 1

In many builds, user_rotation values map like this:

  • 0 for portrait
  • 1 for landscape
  • 2 for reverse portrait
  • 3 for reverse landscape

To restore sensor-based rotation:

bash
adb shell settings put system accelerometer_rotation 1

This gives tests a predictable orientation without manual clicking.

When the app blocks rotation

An app can opt out of normal rotation. For example, an activity can be pinned to portrait in the manifest:

xml
<activity
    android:name=".MainActivity"
    android:screenOrientation="portrait" />

With that attribute, the emulator rotates but the activity stays portrait. Apps that handle configuration changes manually may also not recreate the activity the way you expect.

To see the normal recreation flow, leave the system in control and log the lifecycle callbacks:

kotlin
1override fun onCreate(savedInstanceState: Bundle?) {
2    super.onCreate(savedInstanceState)
3    Log.d("MainActivity", "onCreate")
4}
5
6override fun onDestroy() {
7    super.onDestroy()
8    Log.d("MainActivity", "onDestroy")
9}

Rotating the emulator should trigger a configuration change unless you deliberately overrode that behavior.

Testing orientation beyond phone rotation

To check layout adaptation, the toolbar is enough. For deterministic automated tests, use adb or instrumented tests that change orientation explicitly.

Tablets, foldables, and resizable emulator devices expose layout bugs that a simple portrait-to-landscape switch misses. This is especially true for adaptive layouts: a screen can pass a basic rotation test and still fail when width classes or multi-window constraints change.


Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms