如何导航到Half Fragment? (导航架构组件) [英] How to navigate to Half Fragment ? (Navigation Architecture Component)

本文介绍了如何导航到Half Fragment? (导航架构组件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中导航架构组件. 早些时候,我使用碎片交易来实现以下功能. 基本上我想从中导航.

I am trying Navigation architecture Component in My app. Earlier i Used Fragment Transaction's to achieve the below feature. Basically i want to navigate from.

FragmentA-> FragmentB (自定义片段部分透明,只有屏幕大小的一半)

如果我使用的是导航组件,请尝试

If i am using Navigation component and try

Navigation.findNavController(view).navigate(R.id.action_FragmentA_to_FragmentB)

然后结果是将FragmentA替换为FragmentB,并且背景片段不可见.

Then the result is the FragmentA is replaced by FragmentB and the background fragment is not visible.

我想知道一个解决方案,如果导航架构组件允许的话.

P.S:我听说过嵌套的导航主机,但是从Fragment内部使用会很好.

更新:

FragmentB将具有用于进一步交易的动作,并且 例如:

The FragmentB will have action's for further transaction's and example:

FragmentA-> FragmentB-> FragmentC (自定义片段部分透明,只有屏幕大小的一半)

当用户按下后退"按钮时,Fragment C应该替换FragmentB,并且应该为所有碎片事务维护backStack.

And Fragment C should replace FragmentB when user press back button and backStack should be maintained for all the fragment transactions.

推荐答案

TLDR:我使用嵌套图来满足要求.

您好,谢谢您的帮助,但是我可以按照以下步骤在BottomSheet中进行导航.

Hello, thanks for help but navigating in BottomSheet is achieved by me using below procedure.

  • MainActivity

  • NavHost( FragXYZ-> FragA )
    • (内部片段A )BottomSheetDialogFragment.show()以显示bottomSheetMenu
      • (在片段B内部)BottomSheetDialog 片段(使用Fragment开始BottomSheetDialogFragment的子片段 交易)扩展了NavHostFragment
      • NavHost(FragXYZ->FragA)
        • (Inside Fragment A)BottomSheetDialogFragment.show() to display the bottomSheetMenu
          • (Inside Fragment B) BottomSheetDialogChildFragment(start child Fragment of BottomSheetDialogFragment using Fragment Transaction) extends NavHostFragment

          演示: GitHub

          这篇关于如何导航到Half Fragment? (导航架构组件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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