Navigation Preview unavailable in Android Studio 3.2 Preview

there is another way to have the preview in navigation xml. First go in your xml fragment add

tools:context="com.packagename.nameFragment"

exemple for my frag layout

And that's it

if you go in your navigation file you can see the preview inside the selection and the navigation editor

enter image description here enter image description here

And if you look in the code is auto write

tools:layout="@layout/layout_name"

For me is more logic to have the preview before add the fragment in the navigation editor. May be there are method for add automatically the tools:context in the layout

Autocompletation not suggest for tools:context Fragment only suggest the tools:context Activity host so you need to write the fragment's name... if someone have a trick for this

learn more about tools:context : enter link description here


You should click on "text" tab in navigation editor (xml file of the navigation graph), and add:

tools:layout="@layout/layout_name"

inside destination element.

Should be something like this:

<fragment
    android:id="@+id/someFragment"
    android:name="com.freesoulapps.navigationtest.fragments.SomeFragment"
    android:label="Some Fragment"
    tools:layout="@layout/layout_name">
</fragment>

Just add tools:layout="fragmentname" to every fragment whose preview is not visible. Example:-

<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/nav_graph"
    app:startDestination="@id/startFragment">

    <fragment
        android:id="@+id/pickupFragment"
        android:name="com.example.cup_cake.PickupFragment"
        android:label="fragment_pickup"
        tools:layout="@layout/fragment_pickup" />

</navigation>