Second level child fragment hides the parent fragment

17 Views Asked by At

I have a main activity with a nav host fragment and four fragments. One of the four is the root of the navigation tree, the three others are children fragments. This works fine. Now I want to add an additional fragment as child of one of the three secondary fragments. What I do not achieve is to have the additional fragment to superpose to its parent instead of covering it. This is reflected by the navigation graph preview. By the way, I tried to insert a nav_host_fragment widget in the layout of the secondary fragment but this was totally ignored by the navigation graph.

[![enter image description here][1]][1]

Why does the target icon of fragmentSaisie not appear on the layout of fragmentJeu ?

Here is the XML of fragmentSaisie:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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/constraint_layout3"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".FragmentSaisie">

    <Button
        android:id="@+id/button2"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_marginBottom="168dp"
        android:background="@drawable/button"
        android:gravity="center"
        android:textAlignment="gravity"
        app:icon="@drawable/arrow_12768981"
        app:iconGravity="textStart"
        app:iconPadding="0dp"
        app:iconSize="50dp"
        app:iconTint="@color/black"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

And here the navigation graph:

<?xml version="1.0" encoding="utf-8"?>
<navigation 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/navigation_graph"
    app:startDestination="@id/fragmentBaseMots">

    <fragment
        android:id="@+id/fragmentBaseMots"
        android:name="com.simonwintz.millemot.FragmentBaseMots"
        android:label="fragment_base_mots"
        tools:layout="@layout/fragment_base_mots" >
        <action
            android:id="@+id/baseMotsToJeu"
            app:destination="@id/fragmentJeu" />
        <action
            android:id="@+id/baseMotsToRefill"
            app:destination="@id/fragmentRefill" />
        <action
            android:id="@+id/baseMotsToPref"
            app:destination="@id/fragmentPref" />
    </fragment>
    <fragment
        android:id="@+id/fragmentJeu"
        android:name="com.simonwintz.millemot.FragmentJeu"
        android:label="fragment_jeu"
        tools:layout="@layout/fragment_jeu" >
        <argument
            android:name="totalMots"
            app:argType="string"
            android:defaultValue='""' />
        <argument
            android:name="totalCoups"
            app:argType="string"
            android:defaultValue='""' />
        <argument
            android:name="totalActifs"
            app:argType="string"
            android:defaultValue='""' />
        <action
            android:id="@+id/jeuToSaisie"
            app:destination="@id/fragmentSaisie" />
    </fragment>
    <fragment
        android:id="@+id/fragmentRefill"
        android:name="com.simonwintz.millemot.FragmentRefill"
        android:label="FragmentRefill"
        tools:layout="@layout/fragment_refill">
        <argument
            android:name="message"
            app:argType="string"
            android:defaultValue="No message!" />
    </fragment>
    <fragment
        android:id="@+id/fragmentPref"
        android:name="com.simonwintz.millemot.FragmentPref"
        android:label="FragmentPref"
        tools:layout="@layout/fragment_pref">
        <argument
            android:name="Message"
            app:argType="string"
            android:defaultValue='"No message!"' />
    </fragment>
    <fragment
        android:id="@+id/fragmentSaisie"
        android:name="com.simonwintz.millemot.FragmentSaisie"
        android:label="fragment_saisie"
        tools:layout="@layout/fragment_saisie" >
        <argument
            android:name="tirage"
            app:argType="string"
            android:defaultValue='""' />
    </fragment>
</navigation>
0

There are 0 best solutions below