繁体   English   中英

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

[英]Setting supports-screens for ionic/ Cordova app in Android

我试图让我的离子/ 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插件添加cordova-custom-config)

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

    从文档:为了在config.xml中的首选项中使用android:namespace,您必须在根<widget>元素上包含android命名空间属性。 命名空间属性片段是:

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

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

在index.html的最开始,使用JavaScript查找设备的窗口高度和窗口宽度,如果它们小于某些数字,则提示用户不支持该设备。

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

使用发布应用

[英]Publishing an App with <supports-screens android:requiresSmallestWidthDp=“600” does not seem to work

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM