Ionic 3 - Hide status bar during splash screen show

我只是一个虾纸丫 提交于 2019-12-04 04:29:56

问题


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

Solutions?


回答1:


Android

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

  1. Find MainActivity.java (maybe platforms/android/src/io/ionic/starter)
  2. Add the below code

import 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

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



来源:https://stackoverflow.com/questions/50976545/ionic-3-hide-status-bar-during-splash-screen-show

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!