1

My activity forces portrait mode using android:screenOrientation="portrait" in the manifest. However, some of my users (on tablets that are by default in landscape mode) have asked me to make this a configurable option. Is it possible to set the orientation in code (without triggering an orientation-change animation, so before the activity is actually displayed)?

Nick
  • 3,486
  • 2
  • 36
  • 77

1 Answers1

1

Yes, simply call:

 Activity.setRequestedOrientation (int requestedOrientation)

Taken from

http://developer.android.com/reference/android/app/Activity.html#setRequestedOrientation%28int%29

If you want to lock the screen orientation after setting it, take a look at this post:

Screen orientation lock

Community
  • 1
  • 1
Philipp Jahoda
  • 49,738
  • 23
  • 176
  • 183