Get phone orientation but fix screen orientation to portrait

前端 未结 7 1220
忘了有多久
忘了有多久 2020-12-01 09:09

I want to get the phone orientation but keep the screen orientation to portrait. So no matter the user turns the phone to landscape or portrait, the view stays the same, but

7条回答
  •  [愿得一人]
    2020-12-01 09:53

    To get into that you want to set in manifest file in that activity

    android:configChanges="orientation|keyboardHidden"
    

    Then when user rotate phone it will came into public void onConfigurationChanged() method. Also remove

    android:screenOrientation="portrait" 
    

    from the same activity.

提交回复
热议问题