android - ionic 无法使状态栏覆盖

标签 android cordova ionic-framework

我在 Android 上使用 Ionic 时遇到了一些问题。我认为问题发生在我为我的应用程序更新 Ionic 版本时。问题是状态栏没有覆盖 webview。我尝试在 config.xml 中将 StatusBarOverlaysWebView 首选项设置为 true 并且我尝试调用全局 StatusBar 对象的不同方法成功。我可以控制状态栏的背景颜色和可见性,但我无法让它覆盖 webview。这就是它现在的样子 Android Ionic Screenshot statusbar

最佳答案

不幸的是,cordova-plugin-statusbar 中的StatusBarOverlaysWebView 方法is only supported by the iOS platform :

StatusBar.overlaysWebView
On iOS 7, make the statusbar overlay or not overlay the WebView.

StatusBar.overlaysWebView(true);

Description
On iOS 7, set to false to make the statusbar appear like iOS 6. Set the style and background color to suit using the other functions.

Supported Platforms
iOS


这里有一些其他的方法。检查下面的链接(但它似乎不再起作用) http://www.martinadamko.sk/posts/translucent-bar-android-278

或者

这个怎么样?
最简单的方法如下:

/* ionic 2 app.ts */
import { Component } from '@angular/core';
import { Platform, ionicBootstrap } from 'ionic-angular';
import { StatusBar } from 'ionic-native';

@Component({
  template: '<ion-nav [root]="rootPage"></ion-nav>',
})
export class App {
  private rootPage: any;

  constructor(private platform: Platform) {
    this.rootPage = LandingPage;

    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();

      // Status bar theme for android
      if (platform.is('android')) {
        StatusBar.styleLightContent();
        StatusBar.backgroundColorByHexString('#c42626');
      }
    });
  }
}

结果是这样的:

关于android - ionic 无法使状态栏覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37134065/

相关文章:

javascript - phonegap 离线/在线事件不工作

authentication - 像Spring Security这样的GWT用户身份验证?

javascript - Ionic - 后退按钮关闭键盘但输入仍然聚焦

angular - 带有 Angular 9 的 Ionic 5 - Angular JIT 编译失败 : '@angular/compiler' not loaded

java - 如何从Android studio/java中的drawable文件夹中获取图像的内部url?

android - 如何在 Google map 中全天跟踪用户的位置?

android - AppCompat 未显示操作栏

facebook - Cordova facebook OAuth 登录问题

javascript - 在 php 中返回 true 并在 javascript 中获取结果

android - 将 ormlite-4.9 与 sqlcipher-2.08 集成