Ionic 3-在初始屏幕显示期间隐藏状态栏 [英] Ionic 3 - Hide status bar during splash screen show
问题描述
我有一个带有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.
- 找到 MainActivity.java (也许是
platforms/android/src/io/ionic/starter
) - 添加以下代码
- Find MainActivity.java (maybe
platforms/android/src/io/ionic/starter
) - 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
我只能测试Android设备.因此,我只留下了链接可能会解决您的问题
I can only test Android device. So, I just leave the link which may solve your issue
这篇关于Ionic 3-在初始屏幕显示期间隐藏状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!