How to show a fragment layout within a FrameLayout in Android Studio's Layout Editor / Preview?

652 Views Asked by At

I have an empty FrameLayout in an Activity's xml file. I add a Fragment to it programmatically in the Activity onCreate(), and everything is working fine.

However, I want to be able to see a fragment layout in the Preview Layout Editor in Android Studio.

tools:layout="@layout/fragment_cities

works to show a layout if we are using the <fragment> tag in xml, but not for FrameLayout.

Is there a way to show a layout preview in the FrameLayout?

// does not work
 <FrameLayout
            android:id="@+id/container_frame_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toTopOf="parent"
            tools:layout="@layout/fragment_cities"
            />
    ```
0

There are 0 best solutions below