【问题标题】:Cordova hide statusbar during show splashscreenCordova 在显示初始屏幕期间隐藏状态栏
【发布时间】:2017-01-11 08:30:43
【问题描述】:

通过插件 cordova-plugin-splashscreen 显示的闪屏。但是当应用程序启动并显示启动画面时,状态栏并未隐藏。显示启动画面时如何隐藏状态栏?我找到了这个解决方案:

How to completely hide the status bar in iOS using Cordova?

但它适用于 iOS。我的平台是安卓。

【问题讨论】:

    标签: android cordova cordova-plugins


    【解决方案1】:

    在 ionic 3 应用程序中,如果 <preference name="Fullscreen" value="true" /> 没有工作,请执行以下操作:

    1. 安装全屏插件:

      ionic cordova plugin add cordova-plugin-fullscreen
      npm install --save @ionic-native/android-full-screen
      
    2. 将此添加到config.xml 文件以自定义主题:

      <widget ... xmlns:android="http://schemas.android.com/apk/res/android">   // note this xmlns:android line
          <platform name="android">
          ...
          <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
            <activity android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
          </edit-config>
        </platform>
      </widget>
      
    3. src/app/app.module.ts中添加全屏提供者:

      ....
      // add this line at the top of the file, import it
      import {AndroidFullScreen} from "@ionic-native/android-full-screen";
      ...
      providers: [
        StatusBar,
        SplashScreen,    
        {provide: ErrorHandler, useClass: IonicErrorHandler},
        AndroidFullScreen,   // here add this line
        ...
      ]
      
    4. src/app/app.components.ts中使用它:

      // add this line at the top of the file, import it
      import {AndroidFullScreen} from "@ionic-native/android-full-screen";
      ...
      constructor(public platform: Platform,
                  public statusBar: StatusBar,
                  public splashScreen: SplashScreen,
                  public androidFullScreen: AndroidFullScreen) {
      
        // show statusbar
        this.androidFullScreen.isSupported()
          .then(() => this.androidFullScreen.showSystemUI());
      
        // style statusbar and hide splash
        this.platform.ready().then(() => {
            this.statusBar.styleDefault();
            this.splashScreen.hide();
        });
      }
      ...
      

    【讨论】:

    • 像魅力 +1 一样工作
    • 但我需要将 de 包版本更改为:npm install --save @ionic-native/android-full-screen@4
    【解决方案2】:

    对于 Android,如果您有单色背景的飞溅,请将状态栏更改为相同颜色。

    styles.xml 中添加以下内容(我正在显示白色背景的状态栏)

        <style name="AppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
            <item name="android:statusBarColor">@android:color/white</item>
        </style>
    
        <style name="AppTheme.NoActionBarLaunch" parent="AppTheme.NoActionBar">
            <item name="android:statusBarColor">@android:color/white</item>
        </style>
    

    【讨论】:

      猜你喜欢
      • 2018-12-01
      • 1970-01-01
      • 2020-01-10
      • 2013-11-02
      • 2017-10-18
      • 2016-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多