Layout editor: How to show layout in framelayout container?

2.5k views Asked by At

I have a layout defined in XML as root ConstraintLayout that contains 4 empty frameLayouts for dynamically inflating fragments. In order to have a better design experience in the layout editor (Android Studio), is there a way to show/mimic the intended layouts in each of these framelayouts?

This question is not about loading a fragment in a container dynamically (in the code), I am looking for a solution that will allow me to load a layout in a container/Framelayout in the Layout Editor!

2

There are 2 answers

0
Jan Slominski On

According to my knowledge and answer to this SO question it is not possible. However in the answer to this question you can find a workaround.

0
Abhinav Atul On

A workaround using android:visibilty:"gone"

<FrameLayout
    android:id="@+id/frameLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
    <LinearLayout
        android:id="@+id/doNotUseThisPlaceholder"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:visibility="visible"
        android:visibility="gone"
        tools:ignore="UselessParent">
        <include
            layout="@layout/designTimeLayout" />
    </LinearLayout>
</FrameLayout>