Android screen orientation: forcing landscape?

2019-09-02 03:11发布

问题:

When I switch to a certain activity, I want that activity to show up in landscape mode.

In my XML for that actvitiy:

android:screenOrientation="landscape"

most tutorials stated this is all that's needed, yet when that activity is switched to it doesn't automatically change orientation.

fixed: the code needed to be in the manifest under the specific activity

回答1:

In your activity tag, instead of just:

android:screenOrientation="landscape"

I would set:

 android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden"

It takes care of a few more things for you.



回答2:

fixed: the code needed to be in the manifest under the specific activity