Skip to content Skip to sidebar Skip to footer

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?

Solution 1:

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

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

android:configChanges = "orientation"

Solution 2:

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

Solution 3:

yes this one possible

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Post a Comment for "Change Orientation At Runtime"