Change orientation at runtime

前端 未结 3 967
后悔当初
后悔当初 2020-12-10 04:50

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

相关标签:
3条回答
  • 2020-12-10 05:05

    yes this one possible

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    0 讨论(0)
  • 2020-12-10 05:08
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    

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

    android:configChanges = "orientation"
    
    0 讨论(0)
  • 2020-12-10 05:23

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

    0 讨论(0)
提交回复
热议问题