Can't remove space on top of nav_host_fragment : <p>I just implemented a bottom navigation (AS's default - File -> New -> Activity -> Bottom Navigation Activity) Everything is fine except for a space on the top of the <code>nav_host_fragment</code>. </p>

<p><img src="https://i.ibb.co/vwYBJPG/space.png" alt="wrong space"></p>

<p>Since it was generated in a ConstraintLayout, I tried to clean the constraints and set the top constraint with <code>parent</code>, setting <code>margin</code> to '0dp' and set <code>height</code> to <code>match_constraint</code>.</p>

<p>I unsuccessfully deleted the constraints and tried over and over again.</p>

<p>I used <code>Clean Project</code>.</p>

<p>I changed to RelativeLayout and set arguments like this:</p>

<pre><code> &lt;fragment
            android:id="@+id/nav_host_fragment"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_above="@+id/nav_view"
            app:defaultNavHost="true"
            app:navGraph="@navigation/mobile_navigation" /&gt;
</code></pre>

<p>But the space between <code>nav_host_fragment</code> and the top is still there.</p>

<p>Here's the lyout file:</p>

<pre><code>&lt;RelativeLayout 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/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="?attr/actionBarSize"&gt;

    &lt;com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/nav_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="?android:attr/windowBackground"
            app:menu="@menu/bottom_nav_menu" /&gt;

    &lt;fragment
            android:id="@+id/nav_host_fragment"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_above="@+id/nav_view"
            app:defaultNavHost="true"
            app:navGraph="@navigation/mobile_navigation" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>
