При использовании хост-компонента навигации Jetpack у меня возникает проблема с навигацией «Поведение всплывающих окон», использующей анимацию, отличную от той, которую я хотел бы, и я не уверен, как вызвать другую.
При перемещении между экранами я пытаюсь заставить их «течь справа налево», аналогично навигации в iOS.Однако, когда я добавляю всплывающее поведение, чтобы Fragment 3
возвращалось прямо к Fragment 1
, при переходе от Fragment 2
к Fragment 3
Fragment 2
перемещалось вправо, а не влево.
Я воспроизвел проблему в этом хранилище: https://github.com/AtomicSimon/Android-Replication-Screen-Flow
Вот простой экранный поток, который я использую:
Вот график навигации XML:
<fragment
android:id="@+id/fragment_1"
android:label="fragment_fragment_1"
android:name="com.example.android_replication_screen_flow.fragment_1"
tools:layout="@layout/fragment_fragment_1">
<action
android:id="@+id/action_fragment_1_to_fragment_2"
app:destination="@id/fragment_2"
app:enterAnim="@anim/slide_in_from_the_right"
app:exitAnim="@anim/slide_out_to_the_left"
app:popEnterAnim="@anim/slide_in_from_the_left"
app:popExitAnim="@anim/slide_out_to_the_right"/>
</fragment>
<fragment
android:id="@+id/fragment_2"
android:label="fragment_fragment_2"
android:name="com.example.android_replication_screen_flow.fragment_2"
tools:layout="@layout/fragment_fragment_2">
<action
android:id="@+id/action_fragment_2_to_fragment_3"
app:destination="@id/fragment_3"
app:enterAnim="@anim/slide_in_from_the_right"
app:exitAnim="@anim/slide_out_to_the_left"
app:popEnterAnim="@anim/slide_in_from_the_left"
app:popExitAnim="@anim/slide_out_to_the_right"
app:popUpTo="@+id/fragment_2"
app:popUpToInclusive="true"/>
</fragment>
<fragment
android:id="@+id/fragment_3"
android:label="fragment_fragment_3"
android:name="com.example.android_replication_screen_flow.fragment_3"
tools:layout="@layout/fragment_fragment_3"/>
Я бы хотел, чтобы Fragment 2
покинул экран влево при переходе от Fragment 2
к Fragment 3
, но я не могу сделать это правильно.