jayellos
jayellos

Reputation: 691

Change orientation at runtime

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

Upvotes: 11

Views: 3920

Answers (3)

Android
Android

Reputation: 1427

yes this one possible

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Upvotes: 3

Bigflow
Bigflow

Reputation: 3666

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

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

android:configChanges = "orientation"

Upvotes: 20

Alix Bloom
Alix Bloom

Reputation: 217

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

Upvotes: 3

Related Questions