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

时间:2022-06-02 22:57:56

I am trying to make my ionic/ Cordova app to not support small screens. So I have this below inside my config.xml at the root of the project folder :

我试图使我的离子/ Cordova应用程序不支持小屏幕。所以我在项目文件夹根目录下的config.xml中有以下内容:

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

Although the config.xml generated inside \platform\android\res\xml\ has the below content fine:<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具有以下内容:

, the output AndroidManifest.xml shows <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true"/>.

,输出AndroidManifest.xml显示

So basically, my screen related config is ignored, it only do the default.

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

How do I actually turn off small screen support?

我如何实际关闭小屏幕支持?

2 个解决方案

#1


2  

  1. Make sure you have installed the cordova-custom-config plugin (cordova plugin add cordova-custom-config)

    确保你已经安装了cordova-custom-config插件(cordova插件添加cordova-custom-config)

  2. Make sure you have added the Android namespace attribute

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

    From the documentation : In order to user the android: namespace in preferences within your config.xml, you must include the android namespace attribute on the root <widget> element. The namespace attribute fragment is:

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

     xmlns:android="http://schemas.android.com/apk/res/android"
    
  3. Make sure you have defined <config-file target="AndroidManifest.xml" parent="/*"> element inside the android platform element (<platform name="android">), otherwise it will be ignored.

    确保在android平台元素( )中定义了 元素,否则将被忽略。

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

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

#2


-2  

at the Very beginning of your index.html, use JavaScript to find the windowheight and windowwidth of the device, if they are smaller than some figures, prompt the user that the device is not supported.

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

Actually, in my own app, I allow all screen size, but I never use actual figures in my css, for example, I do not use fontsize: 20 px, I set fontsize by JavaScript to a value that equals to some ratio of the screen height, so that no matter how small or big the screen is, all the font-size, image size, table width, whatever, display at a correct ratio in all devices among all platforms.

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

#1


2  

  1. Make sure you have installed the cordova-custom-config plugin (cordova plugin add cordova-custom-config)

    确保你已经安装了cordova-custom-config插件(cordova插件添加cordova-custom-config)

  2. Make sure you have added the Android namespace attribute

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

    From the documentation : In order to user the android: namespace in preferences within your config.xml, you must include the android namespace attribute on the root <widget> element. The namespace attribute fragment is:

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

     xmlns:android="http://schemas.android.com/apk/res/android"
    
  3. Make sure you have defined <config-file target="AndroidManifest.xml" parent="/*"> element inside the android platform element (<platform name="android">), otherwise it will be ignored.

    确保在android平台元素( )中定义了 元素,否则将被忽略。

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

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

#2


-2  

at the Very beginning of your index.html, use JavaScript to find the windowheight and windowwidth of the device, if they are smaller than some figures, prompt the user that the device is not supported.

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

Actually, in my own app, I allow all screen size, but I never use actual figures in my css, for example, I do not use fontsize: 20 px, I set fontsize by JavaScript to a value that equals to some ratio of the screen height, so that no matter how small or big the screen is, all the font-size, image size, table width, whatever, display at a correct ratio in all devices among all platforms.

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