Kotlin 2个NavHostFragments在LayoutSpector中可见,但在我的布局中仅1个
我有过这个问题,对我来说有点奇怪。通过Layout Inspector查看我的应用程序时,我可以看到出于某种原因,我的navHostFragment嵌套在其内部: 但是,以下是我的布局文件的内容:Kotlin 2个NavHostFragments在LayoutSpector中可见,但在我的布局中仅1个,kotlin,android-fragments,androidx,android-jetpack-navigation,Kotlin,Android Fragments,Androidx,Android Jetpack Navigation,我有过这个问题,对我来说有点奇怪。通过Layout Inspector查看我的应用程序时,我可以看到出于某种原因,我的navHostFragment嵌套在其内部: 但是,以下是我的布局文件的内容: <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.andr
<androidx.drawerlayout.widget.DrawerLayout 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"
android:id="@+id/activity_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
tools:context=".core.MainActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/activity_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/navHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
我没有在片段容器视图中膨胀另一个navHostFragment,那么为什么navHostFragment在layout inspector中重复?这是正常的还是隐藏的navHostFragment被膨胀了?进一步测试后,这一额外的层似乎是在使用时生成的