我有一个布局文件activity_main.xml,其中包含一个全屏场景形式片段和一个“菜单”导航主机片段,该菜单在打开时会占据屏幕的80%。我有一个按钮可以打开“菜单”。然后,我希望NavHostFragment
/菜单从底部滑入。当我关闭它时,我想{/ {1}} /菜单滑到底部。
这是activity_main.xml文件
NavHostFragment
我尝试过的事情
使用ConstraintLayout和ConstraintSet创建很棒的动画: https://proandroiddev.com/creating-awesome-animations-using-constraintlayout-and-constraintset-part-i-390cc72c5f75
这似乎打乱了AR体验,因为我需要用于同一 <fragment
android:id="@+id/sceneform_fragment"
android:name="com.google.ar.sceneform.ux.ArFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<fragment
android:id="@+id/fragment_menu_nav_host"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
android:layout_marginTop="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/menu_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
片段的另一个布局文件。
我还尝试过将Sceneform
保留在NavHostFragment
中并为片段事务设置动画。但是,如果FragmentContainerView
不是直接位于NavHostFragment
布局中,则电话中的后退按钮无法用于导航,似乎片段没有被添加到“导航堆栈”中,
谢谢!