Search code examples
androidandroid-emulatorscreen-orientationandroid-virtual-device

Android Emulator - Screen orientation does not work properly


I created a virtual Android device, 480x800, ran it, and as I already found how to change the screen orientation (portrait-landscape, CTRL+F11/CTRL+F12/KP7/KP9), I used these keys to change the orientation.

But when I try one of these keys, the virtual screen rotates 90 degrees, but the orientation does not change. Hence, the Buttons are vertically placed on the screen, and all the text too. Just like a picture that is getting rotated 90 degrees.

How do I get the virtual degrees to actually switch over to the other layout file (/res/layout-land/activity_entry.xml)? Eclipse's graphical viewer does switching between landscape/portrait correctly.

EDIT
I added this part in the activity right under this the onCreateOptionsMenu(Menu menu) method, but the application does not recognize screen orientation change:

@Override
public void onConfigurationChanged(Configuration newConfig) { 
    super.onConfigurationChanged(newConfig);
    Context context = getApplicationContext();
    CharSequence text = "Orientation changed";
    int duration = Toast.LENGTH_SHORT;

    Toast toast = Toast.makeText(context, text, duration);
    toast.show();
}

EDIT 2
When I call this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) from within the onCreate() method, it works nicely.


Solution

  • First off number lock and then press 7 or press 9 and check emulator's orientation is changed and other way to change orientation of emulator is press ctrl+f12.