gpt4 book ai didi

android - 是否可以仅在带有 cordova 的手机上以纵向模式锁定 android 应用程序?

转载 作者:行者123 更新时间:2023-11-29 14:17:44 26 4
gpt4 key购买 nike

我希望我的应用仅支持以下方向:

  • 在手机上:纵向或反向
  • 在平板电脑上:纵向、反向纵向、横向、反向横向

我找到了很多关于如何在 Android 应用程序中执行此操作的信息,但在 cordova 应用程序中找不到。有没有办法不修改 Java 代码就可以做到这一点?

我已经通过将以下内容添加到我的项目的 plist 文件中解决了 iOS 上的这个问题:

<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>

plist 文件是由 cordova 创建的,它是一个 xml 文件,因此很容易制作一个脚本来在每次构建时添加这些配置。

但在 Android 上,AndroidManifest.xml 中似乎只有一个属性适用于手机和平板电脑。这样做的 cordova 方法是什么?

最佳答案

是的,只有在带有 Cordova/PhoneGap 应用程序的手机上才能以纵向模式锁定 Android 应用程序

首先,打开你的 Cordova/PhoneGap 应用目录,然后找到 config.xml 文件添加这个语法 <preference name="orientation" value="portrait" />

更多信息:Config.xml - Apache Cordova, preference

关于android - 是否可以仅在带有 cordova 的手机上以纵向模式锁定 android 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25993362/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com