首页 文章

导航体系结构组件导致片段A在片段B进入时消失

提问于
浏览
0

我正在尝试使用导航架构组件实现下面的片段转换 . 使用片段管理器启动片段时,此动画非常有效 . 但是对于导航架构组件,当片段B进入时,片段A消失 . 我使用了假动画,它对片段A没有任何作用,但它仍然无济于事 . 我有什么想法可以解决它吗?

enter image description here

这是我在nav_graph.xml中的代码

<fragment
    android:id="@+id/fragmentA"
    android:name="xxxx.FragmentA"
    android:label="FragmentA"
    tools:layout="@layout/fragment_a" >
    <action
        android:id="@+id/action_fragmentA_to_fragmentB"
        app:destination="@id/fragmentB"
        app:enterAnim="@anim/slide_in_from_bottom"
        app:exitAnim="@anim/fake_anim" />
</fragment>

slide_in_from_bottom.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:shareInterpolator="true">
    <translate android:duration="250" android:fromYDelta="100%" android:toYDelta="0%" />
</set>

fake_anim.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha
        android:fromAlpha="1.0"
        android:toAlpha="1.0"
        android:duration="250" />
</set>

1 回答

相关问题