Ionic 3 - 在初始屏幕显示期间隐藏状态栏 [英] Ionic 3 - Hide status bar during splash screen show

查看:18
本文介绍了Ionic 3 - 在初始屏幕显示期间隐藏状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 Ionic 3 的应用程序,在您的 app.component.ts 中,我使用 Statusbar ionic 插件来隐藏它,但是,这仅在触发平台就绪后才会发生.

I have an app with Ionic 3 and in your app.component.ts, i using the Statusbar ionic plugin to hide that, but, this occurs only after platform ready is fired.

如何在启动画面中隐藏它?我试过了:

How do i hide that during splashscreen? I tried:

– 在启动画面期间不隐藏,仅在此隐藏之后- 在启动画面期间不改变背景颜色

– Not hide during splashscreen, only after this hide – Not change background color during splashscreen

解决方案?

推荐答案

Android

似乎没有优雅的方式在应用启动时隐藏状态栏.但有一种方法可以做到这一点.

It seems that there is not elegant way to hide statusbar on app launch. But there is an way to do that.

  1. 找到 MainActivity.java(可能是 platforms/android/src/io/ionic/starter)
  2. 添加以下代码

导入android.view.WindowManager;

public class MainActivity extends CordovaActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        // enable Cordova apps to be started in the background
        Bundle extras = getIntent().getExtras();
        if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
            moveTaskToBack(true);
        }
        // [Hyuck] add this two line below    
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

        // Set by <content src="index.html" /> in config.xml
        loadUrl(launchUrl);
    }

    // [Hyuck] onStart() is totally new.
    @Override
    public void onStart()
    {
        super.onStart();
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    }
}

IOS

我只能测试 Android 设备.所以,我只留下 链接 这可能会解决您的问题

I can only test Android device. So, I just leave the link which may solve your issue

这篇关于Ionic 3 - 在初始屏幕显示期间隐藏状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆