6

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!

Kamy
  • 586
  • 4
  • 18

2 Answers2

1

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.

Community
  • 1
  • 1
Jan Slominski
  • 2,968
  • 4
  • 35
  • 61
0

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>
Abhinav Atul
  • 601
  • 6
  • 14