Reputation: 691
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
Reputation: 1427
yes this one possible
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Upvotes: 3
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
Reputation: 217
Yes, use setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); to force orientation
Upvotes: 3