使用步骤
-
- 创建Fragments
-
- 在res 下创建navigation文件夹,然后在里面创建 Navigation Resource File,创建完成后文件里面会生成 标签
-
- 在 标签中使用 标签 注册创建的Fragments, demo 如下:
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
app:startDestination="@id/fragment_first">
<fragment
android:id="@+id/fragment_first"
android:name="com.google.samples.apps.sunflower.test.FirstFragment"
tools:layout="@layout/fragment_first">
<action
android:id="@+id/action_first_to_second"
app:destination="@id/fragment_second"
app:enterAnim="@anim/fragment_fade_enter"
app:exitAnim="@anim/fragment_fade_exit"
app:launchSingleTop="true"
app:popEn