11

I'm new to android my question is, Is it possible to change orientation programmatically? If yes, how can we do that?

Ganapathy C
  • 5,989
  • 5
  • 42
  • 75
jayellos
  • 691
  • 1
  • 14
  • 32

3 Answers3

20
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Also add this in your manifest file (under activity):

android:configChanges = "orientation"
Bigflow
  • 3,616
  • 5
  • 29
  • 52
3

Yes, use setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); to force orientation

Alix Bloom
  • 217
  • 1
  • 8
3

yes this one possible

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Android
  • 1,417
  • 9
  • 11