小编Wav*_*cle的帖子

NavHostFragment 与 FragmentContainerView [Android]

您好,我正在浏览 Android 开发人员网站上的导航指南,并按照说明创建了一个NavHostFragment

<fragment
        android:id="@+id/nav_host_fragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"

        app:defaultNavHost="true"
        app:navGraph="@navigation/nav_graph" />
Run Code Online (Sandbox Code Playgroud)

然而,当该代码存在时,IDE 建议我将其替换NavHostFragmentFragmentContainerView.

它们有什么区别?什么时候应该使用它们而不是另一个?

谢谢

android android-studio android-architecture-navigation android-jetpack-navigation

6
推荐指数
1
解决办法
4585
查看次数