简体   繁体   English

当我使用导航组件时,在启动片段之前显示 3 秒的空白屏幕?

[英]Blank screen show for 3 second before splash fragment while i Using Navigation component?

I have an Activity to navigate the splash fragment in default but before showing splash fragment show a blank screen for three seconds and then show the splash fragment.我有一个 Activity 可以在默认情况下导航启动片段,但在显示启动片段之前显示一个空白屏幕三秒钟,然后显示启动片段。 While I used the Navigation Component for fragment navigation.虽然我使用导航组件进行片段导航。 Please correct me if anyone knows.如果有人知道,请纠正我。

NavHostFragment navHostFragment;
NavController navController;
navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
        if (navHostFragment != null) {
            navController = navHostFragment.getNavController();
        }
        navController.navigate(R.id.splashFragment);

I solve my problem by adding this line to the activity theme.我通过将此行添加到活动主题来解决我的问题。

<item name="android:windowIsTranslucent">true</item>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM