Android的导航组件可用于在BottomSheet内进行导航(即在单个底表中替换/添加片段)吗?
我知道如何使用导航图内的BottomSheetDialogFragment
标签启动<dialog>
。例如,下面的nav_graph.xml
允许用户从一个BottomSheetDialogFragment
(fragmentOne)导航到另一个BottomSheetDialogFragment
(fragmentTwo)。 FragmentTwo在FragmentOne的BottomSheet上作为第二个BottomSheet打开。
但是,如果我想让fragmentTwo在相同的BottomSheet中替换fragmentOne,该怎么办?如何使用导航图完成此操作?
<navigation android:id="@+id/nav_graph"
app:startDestination="@id/fragmentOne">
<dialog android:id="@+id/fragmentOne"
android:name="com.example.navcomponentapp.FragmentOne"
android:label="fragment_fragment_one"
tools:layout="@layout/fragment_fragment_one">
<action android:id="@+id/action_fragmentOne_to_fragmentTwo2"
app:destination="@id/fragmentTwo"/>
</dialog>
<dialog android:id="@+id/fragmentTwo"
android:name="com.example.navcomponentapp.FragmentTwo"
android:label="fragment_fragment_two"
tools:layout="@layout/fragment_fragment_two"/>
</navigation>
演示(这不是我想要的。我不希望在另一个bottomSheet上方打开bottomSheet