问题
I'm new to android my question is, Is it possible to change orientation programmatically? If yes, how can we do that?
回答1:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Also add this in your manifest file (under activity):
android:configChanges = "orientation"
回答2:
Yes, use setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); to force orientation
回答3:
yes this one possible
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
来源:https://stackoverflow.com/questions/9837184/change-orientation-at-runtime