5

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.

MC Emperor
  • 22,334
  • 15
  • 80
  • 130
stealthjong
  • 10,858
  • 13
  • 45
  • 84

7 Answers7

4

check in settings tab if auto rotated is enabled, if it's turned off turn it on, then whenever you click rotation button it will rotate by himself

enter image description here

onik
  • 1,579
  • 1
  • 11
  • 19
2

Check whether you have set any android:screenOrientation in the Manifest file for that acitvity. If yes, remove it and check.

If not working, it seems like a bug reported in android issues forums. Check here

Eldhose M Babu
  • 14,382
  • 8
  • 39
  • 44
1

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.

Walid Hossain
  • 2,724
  • 2
  • 28
  • 39
Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
  • 2
    both KP9 and KP7 rotate the AVD 90 degrees, but the screen isn't rearranged, everything is just 90 degrees rotated, like an image – stealthjong Aug 27 '12 at 13:47
  • 1
    Why is this considered an answer to the question? It doesn't matter whether you hit CTRL F12 or Num Pad 7 or Num Pad 9 or .... The emulator program rotates, but the application doesn't get notified. – Dale Wilson Feb 17 '14 at 21:58
  • I've tried it with the simplest possible hello world app on multiple releases of Android with or without Google API's. With or without hardware keyboard enabled. With or with snapshots. With or without using the GPU. With Eclipse or with Android studio. It just doesn't work! (it used to long ago.) – Dale Wilson Feb 17 '14 at 22:00
1

You may find, like I did that the orientation change was actually effected but the screen only changed a few seconds later than you would expect. In other words, the answer might be "patience grasshopper."

Tash Pemhiwa
  • 7,590
  • 4
  • 45
  • 49
0

I ran into this recently and the answer provided here did not solve it. However I found this post:

Android emulator not rotating to landscape

Which mentions that there is a bug in some of the emulator targets (19 for example which I was using).

Simply changing the target to 17 made the rotation start working correctly.

Community
  • 1
  • 1
K5 Studios
  • 101
  • 1
  • 3
0

First need to check in manifeast file you are setting android:screenOrientation="portrait" if yes then remove it. It's working for me.

Ole Pannier
  • 3,208
  • 9
  • 22
  • 33
0

Cold booting android emulator helps me to resolve the orientation not working issue. enter image description here

Nidhin
  • 1,818
  • 22
  • 23