javascript PhoneGap 在单页上禁用屏幕旋转?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10361070/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PhoneGap Disable Screen Rotate On Single Page?
提问by nomaam
I am using PhoneGap, and am working with an Android web based app.
我正在使用 PhoneGap,并且正在使用基于 Android 网络的应用程序。
How do I disable screen rotation for only one page?
如何仅禁用一页的屏幕旋转?
I have searched for this solution but all the solutions say to disable screen rotation in the AndroidManifest.xml file. However, this disables rotation for the whole app. I only need to disable rotation for one page.
我已经搜索了这个解决方案,但所有的解决方案都说在 AndroidManifest.xml 文件中禁用屏幕旋转。但是,这会禁用整个应用程序的旋转。我只需要禁用一页的旋转。
Can this be done using PhoneGap / Javascript code? I am not using any Java code.
这可以使用 PhoneGap / Javascript 代码完成吗?我没有使用任何 Java 代码。
Thanks.
谢谢。
采纳答案by MaramTech
I know this post is a few months old but there is a plugin for phonegap which can help you... It is a plugin that can lock or unlock screen orientation.
我知道这篇文章已经有几个月了,但是有一个 phonegap 插件可以帮助你...这是一个可以锁定或解锁屏幕方向的插件。
回答by bichehype
You can simply remove the following tag or set it at 'portrait' in your config.xml file :
您可以简单地删除以下标记或将其设置为 config.xml 文件中的“portrait”:
<preference name="orientation" value="portrait" />
For more informations, read the phonegap documentation :
有关更多信息,请阅读 phonegap 文档:
回答by Phong NGUYEN
This is simple way to lock rotation:
这是锁定旋转的简单方法:
1/. Edit in config.xml file:
1/。在 config.xml 文件中编辑:
<preference name="orientation" value="portrait" />
2/. Put this code into Android Manifestxml file in:
2/。将此代码放入 Android Manifestxml 文件中:
<activity>
...
android:screenOrientation="portrait"
...
</activity>