【问题标题】:Setting supports-screens for ionic/ Cordova app in Android在 Android 中为 ionic/ Cordova 应用程序设置支持屏幕
【发布时间】:2015-06-05 14:18:50
【问题描述】:

我正在尝试让我的 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 显示&lt;supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true"/&gt;

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

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

【问题讨论】:

  • 我尝试了相同的解决方案并得到了相同的结果。你有其他解决方案吗?

标签: android xml cordova ionic-framework ionic


【解决方案1】:
  1. 确保你已经安装了cordova-custom-config插件(cordova plugin add cordova-custom-config)

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

    来自文档:为了在 config.xml 中的首选项中使用 android: 命名空间,您必须在根 &lt;widget&gt; 元素中包含 android 命名空间属性。命名空间属性片段为:

      xmlns:android="http://schemas.android.com/apk/res/android"
    
  3. 确保你在android平台元素(&lt;platform name="android"&gt;)中定义了&lt;config-file target="AndroidManifest.xml" parent="/*"&gt;元素,否则会被忽略。

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

【讨论】:

    【解决方案2】:

    在你的index.html的最开始,使用JavaScript查找设备的windowheight和windowwidth,如果小于某些数字,提示用户该设备不支持。

    实际上,在我自己的应用程序中,我允许所有屏幕尺寸,但我从不在我的 css 中使用实际数字,例如,我不使用 fontsize: 20 px,我通过 JavaScript 将 fontsize 设置为等于一些的值屏幕高度的比例,这样无论屏幕大小,所有的字体大小,图像大小,表格宽度等等,在所有平台的所有设备上都以正确的比例显示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多