2

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"
            />
    ```
Jeff Padgett
  • 2,380
  • 22
  • 34
  • 1
    For testing purpose only you can try Using [This](https://stackoverflow.com/a/23944452/4168607) but you will have to remove it afterwards . – ADM Aug 25 '20 at 04:10

0 Answers0