Android
emulator
display rotation
troubleshooting
duplicate question

How do I rotate the Android emulator display?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

Rotating the Android emulator is usually straightforward, but the visible result depends on both the emulator controls and your app configuration. If rotation appears to do nothing, the emulator is often fine and the app is simply locking orientation or not recreating the activity the way you expect.

Rotate From the Emulator UI

The fastest method is to use the emulator's built-in rotate controls. In Android Studio, start the emulator, then use the toolbar buttons for rotate left or rotate right. Those buttons simulate a device orientation change and are usually enough when you are just testing layout behavior.

If you prefer the command line or need repeatable steps for debugging, you can rotate the emulator with adb by disabling auto-rotate and setting a fixed rotation value.

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

Typical values for user_rotation are:

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

To restore normal auto-rotation behavior:

bash
adb shell settings put system accelerometer_rotation 1

This is useful when testing a bug report because you can reproduce the same orientation every time.

Verify That the App Allows Rotation

If the emulator rotates but the app does not, check the manifest. Many apps deliberately lock the activity to portrait or landscape.

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

With that setting, the emulator can rotate but the activity will stay portrait. If you want the app to follow the device orientation, remove the android:screenOrientation attribute or set a value that matches your test scenario.

It is also worth checking whether your app handles configuration changes manually. For many apps, the default behavior is enough: Android recreates the activity and reloads resources for the new orientation. If you have custom handling, make sure it is actually updating the UI.

Test Rotation Behavior in Code

A common reason people test emulator rotation is to confirm that layout changes or state restoration work correctly. The example below logs the current orientation from an activity:

kotlin
1import android.content.res.Configuration
2import android.os.Bundle
3import android.util.Log
4import androidx.appcompat.app.AppCompatActivity
5
6class MainActivity : AppCompatActivity() {
7    override fun onCreate(savedInstanceState: Bundle?) {
8        super.onCreate(savedInstanceState)
9
10        val orientation = resources.configuration.orientation
11        val label = when (orientation) {
12            Configuration.ORIENTATION_LANDSCAPE -> "landscape"
13            Configuration.ORIENTATION_PORTRAIT -> "portrait"
14            else -> "undefined"
15        }
16
17        Log.d("RotationDemo", "Current orientation: $label")
18    }
19}

Run the app, rotate the emulator, and watch Logcat. If the activity restarts and prints the new value, rotation is working. If it never changes, the orientation is probably locked somewhere in the app or device settings.

Know What Rotation Actually Tests

Rotation is not just about the screen turning. It also tests resource selection, activity recreation, and state handling. For example, Android can load different layout resources from layout and layout-land, so a screen may appear correct in portrait and broken in landscape even though rotation itself worked perfectly.

When debugging, separate these concerns:

  • Can the emulator orientation change at all
  • Does the activity allow orientation changes
  • Does the app preserve state after recreation
  • Do landscape resources render correctly

That separation saves time because it keeps you from blaming the emulator for an application issue.

Common Pitfalls

  • Leaving android:screenOrientation="portrait" in the manifest prevents visible rotation even when the emulator rotates correctly.
  • Forgetting to re-enable accelerometer_rotation can make later tests confusing because the device stays locked to one orientation.
  • Assuming a rotated screen means state handling is correct can hide bugs. Activity recreation may still drop form data or selected items.
  • Testing only with the UI rotate buttons can miss automation needs. Use adb when you need a repeatable sequence for scripts or bug reproduction.
  • Treating a layout problem as a rotation problem wastes time. First confirm whether the orientation changed, then inspect resources and lifecycle behavior.

Summary

  • Use the emulator toolbar for quick manual rotation tests.
  • Use adb shell settings put system user_rotation for repeatable command-line control.
  • Check the manifest for android:screenOrientation if the app refuses to rotate.
  • Verify orientation changes in code when debugging layout or lifecycle issues.
  • Separate emulator rotation, activity recreation, and layout rendering into distinct checks.

Related reading
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
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.