可能重复:
How to set android show vertical orientation?禁用自动旋转屏幕 - 安卓
我试图禁用自动旋转,当我运行我的Android应用程序。 也许,我应该在AndroidManifest.xml中添加一行代码 任何人都知道我该怎么做?
可能重复:
How to set android show vertical orientation?禁用自动旋转屏幕 - 安卓
我试图禁用自动旋转,当我运行我的Android应用程序。 也许,我应该在AndroidManifest.xml中添加一行代码 任何人都知道我该怎么做?
在AndroidManifest.xml中加入类似android:screenOrientation="portrait"
或android:screenOrientation="landscape"
:
<activity android:name=".MyActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
一个
android:screenOrientation="<mode>"
属性添加到您的活动。
看到这里的模式:http://developer.android.com/guide/topics/manifest/activity-element.html#screen
<activity android:name=".SomeActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
为肖像模式。
的android:screenOrientation
属性添加到您的<activity />
标签:
<activity android:screenOrientation="landscape"
... >
如需进一步信息和可能值的列表,请访问documentation。
您可以通过添加其他答案中建议的代码,使您的活动保持单一方向模式。处理这个的更完整的方法是在这里:
http://developer.android.com/guide/topics/resources/runtime-changes.html
当你改变方向,你在做什么正在改变应用程序的配置。查看“自己处理配置更改”部分的标题以覆盖默认行为。
http://stackoverflow.com/questions/6119606/how-to-set-android-show-vertical-orientation – DonGru