Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

代码设置NavGraph,二级页面返回后白屏 #16

Open
wsdydeni opened this issue Jan 21, 2022 · 1 comment
Open

代码设置NavGraph,二级页面返回后白屏 #16

wsdydeni opened this issue Jan 21, 2022 · 1 comment

Comments

@wsdydeni
Copy link

我在代码里面初始化navGraph

        val navHostFragment =
            supportFragmentManager.findFragmentById(R.id.nav_host_fragment_identity) as NavHostFragment
        val navController = NavHostFragment.findNavController(navHostFragment)
        navController.setGraph(
            if(authStatus == "1") R.navigation.nav_identity
            else R.navigation.nav_identity_verify
        )

设置了之后,在某个二级页面返回,白屏了

 Navigation.findNavController(requireActivity(),R.id.nav_host_fragment_identity).navigateUp()

第一次设置navGrpah的日志

2022-01-21 16:12:17.797 D/Nav: --isSingleTopReplacement --- false
2022-01-21 16:12:17.797 D/Nav: --mBackStack.size:0 getFragments().size():0
2022-01-21 16:12:17.797 D/Nav: --Replace --- InitiateVerifyFragment{6b983ed} (35176420-6950-4140-97fe-c1951b65d7a9)

跳转二级页面的日志

2022-01-21 16:12:21.625 D/Nav: --isSingleTopReplacement --- false
2022-01-21 16:12:21.625 D/Nav: --mBackStack.size:1 getFragments().size():1
2022-01-21 16:12:21.625 D/Nav: --Add --- UploadVerifyFragment{9c80c27} (b504e152-121d-4bc7-84cf-efa6358bf1ca)
2022-01-21 16:12:21.626 D/Nav: --Hide --- InitiateVerifyFragment{ddb6b77} (55ca39c0-09e1-4355-b0dc-c311cb6af423 id=0

返回的时候没有日志,只隐藏了二级页面,一级页面也没显示,导致白屏了。

@wsdydeni wsdydeni changed the title 返回后白屏 代码设置NavGraph,二级页面返回后白屏 Jan 21, 2022
@wsdydeni
Copy link
Author

去掉了xml里面的动画(自带的动画)之后,行为似乎正常了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant