Change screen orientation in Android without reloading the activity

前端 未结 5 743
梦谈多话
梦谈多话 2020-12-16 10:40

I want to change the orientation programmatically while running my Android App, with these lines of code:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTA         


        
5条回答
  •  南笙
    南笙 (楼主)
    2020-12-16 11:05

    In AndroidManifest file add android:configChanges="orientation" for the activity you want to handle this orientation

    In activity use onConfigurationChange overrided method. Do task you want to handle in orientation change.

提交回复
热议问题