javascript - 使用 Phonegap 在 Android 中隐藏状态栏
问题描述
我想在 Android 上隐藏状态栏。
启动时,我没有状态栏,但顶部有一个灰色栏,状态栏大小。当我使用键盘时,会出现状态栏。
我已经检查了这些答案,但它没有解决我的问题:Hide Status Bar in Android with Phonegap Build
这是我的config.xml
:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Hello world</name>
<description></description>
<author email="" href="http://phonegap.com"></author>
<content src="index.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="14" />
<preference name="orientation" value="landscape" />
<preference name="Fullscreen" value="true" />
<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.3.3" />
<plugin name="cordova-plugin-device" source="npm" spec="~1.1.6" />
<plugin name="cordova-plugin-fullscreen" spec="~1.1.0" />
<plugin name="cordova-plugin-statusbar" spec="~2.4.2" />
<config-file parent="UIStatusBarHidden">
<true/>
</config-file>
<config-file parent="UIViewControllerBasedStatusBarAppearance">
<false/>
</config-file>
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="~6.3.0" />
</widget>
我也把这段代码放在JS
:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
StatusBar.hide();
if (typeof AndroidFullScreen !== 'undefined') { // Fullscreen plugin exists ?
function errorFunction(error) { console.error(error); }
AndroidFullScreen.isSupported(AndroidFullScreen.immersiveMode, errorFunction);
}
}
解决方案
为了解决这个问题,我在我的 config.xml 中添加了这个首选项:
<preference name="StatusBarOverlaysWebView" value="true" />
推荐阅读
- docker - 将 k3d 迁移/移动到另一台服务器
- php - 记录不存在时显示消息
- sql - 按 ID 和最小/最大日期对二进制变量进行分组
- java - JFormattedTextFields 中的两位数日期
- javascript - CSS网格布局自动调整列和行
- javascript - React + Spring Boot - universall-cookies ,无法设置 httpOnly cookie
- jsonschema - 如何在所需的anyOf jsonSchema中使用anyof?
- javascript - 如何使用打字稿编写一个能够从对象数组中添加或替换元素的函数
- python - 填补时间序列熊猫数据框中的空白
- gantt-chart - 从特定日期开始的 Tableau 甘特条着色