Android natural sensor orientation help

前端 未结 1 1547
一整个雨季
一整个雨季 2021-01-03 09:26

I am trying to accomplish Reto Meier\'s recommended way for keeping the screen orientation from changing. The slides from his talk during Google IO (see #23) can be found in

相关标签:
1条回答
  • 2021-01-03 09:42

    All 30+ lines of code that currently are not working can be replaced with some XML values in your AndroidManifest.xml file.

    We have all seen

    <activity android:name=".YourActivity" android:screenOrientation="portrait" ></activity>
    

    and we all know that doesn't work well with tablets that have a default orientation of landscape. But how many of you have seen this?

    <activity android:name=".YourActivity" android:screenOrientation="nosensor" ></activity>
    

    Basically it makes it so that the device's orientation doesn't respond to the sensor. So if your default is landscape or portrait it won't change. I have tested it on my Droid X and on a Xoom and it works like I would have expected it to.

    I hope this helps others.

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