当回到HomeFragment(即起始目的地)时,如何清除所有堆栈,通过Navigation组件使用户在HomeFragment上按下返回键时关闭应用。
<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/homeFragment">
<fragment android:id="@+id/homeFragment"
android:name="ui.fragment.home.HomeFragment"
tools:layout="@layout/fragmet_home"
android:label="HomeFragment"
app:launchSingleTop="true"
app:popUpToInclusive="true">
<action android:id="@+id/action_homeFragment_to_notificationFragment"
app:destination="@id/notificationFragment"
app:popUpTo="@+id/homeFragment"
app:enterAnim="@anim/pop_enter"
app:exitAnim="@anim/pop_exit"
app:popEnterAnim="@anim/right_in"
app:popExitAnim="@anim/right_out"/>
</Fragment>
<fragment android:id="@+id/notificationFragment"
android:name="ui.fragment.notification.NotificationFragment"
tools:layout="@layout/fragment_notification"/>
</navigation>
2.1.0-alpha06
吗? - solazathis@HomeFragment
而不是Activity
? - solaza