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,889
  • 5
  • 41
  • 73
jayellos
  • 692
  • 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,576
  • 5
  • 27
  • 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,387
  • 8
  • 11