android - 在 Android 中为 ionic/Cordova 应用程序设置支持屏幕

标签 android xml cordova ionic-framework

我正在尝试让我的 ionic/Cordova 应用程序不支持小屏幕。所以我在项目文件夹根目录下的 config.xml 中有这个:

<config-file parent="/" target="AndroidManifest.xml">
    <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="false" />
</config-file>

尽管在\platform\android\res\xml\中生成的config.xml 具有以下内容:<config-file parent="/" target="AndroidManifest.xml"> <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="false" /> </config-file>

,输出 AndroidManifest.xml 显示 <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true"/> .

所以基本上,我的屏幕相关配置被忽略了,它只执行默认设置。

如何真正关闭小屏幕支持?

最佳答案

  1. 确保你已经安装了 cordova-custom-config 插件 (cordova plugin add cordova-custom-config)

  2. 确保您已经添加了 Android 命名空间属性

    来自文档:为了在您的 config.xml 中的首选项中使用 android: 命名空间,您必须在根目录中包含 android 命名空间属性 <widget>元素。命名空间属性 fragment 是:

      xmlns:android="http://schemas.android.com/apk/res/android"
    
  3. 确保你已经定义了<config-file target="AndroidManifest.xml" parent="/*"> android平台元素(<platform name="android">)内的元素,否则将被忽略。

来源:https://www.npmjs.com/package/cordova-custom-config

关于android - 在 Android 中为 ionic/Cordova 应用程序设置支持屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30668889/

相关文章:

Android loopj + GCMIntentService 在死线程上向处理程序发送消息

xml - 如何让 XML IntelliSense 在 VS 2015 中工作?

ios - 使用phonegap在ios中的 native 和网络应用程序中打开谷歌地图

java - 从 Android Phonegap 插件访问应用程序布局

xml - 无法在 import.io 的爬虫中为网页元素获取正确的 XPath

android - 将 native 代码添加到现有的 Worklight 混合应用程序

android - 后退、暂停和转发 GIF

java - 如何将字符串从 Java 服务器类传递到 Android Activity ?

android - 如何将已经编译好的C库添加到Android中?

xml - 如何获取具体元素值