如何在Android Studio的布局编辑器/预览中的FrameLayout中显示片段布局?

问题描述

我在FrameLayout的xml文件中有一个空的Activity。我在Fragment Activity中以编程方式向其中添加onCreate(),一切正常。

但是,我希望能够在Android Studio的“预览布局编辑器”中查看片段布局。

tools:layout="@layout/framgent_cities

如果我们在xml中使用<fragment>标签,而不是FrameLayout,则可以显示布局。

是否可以在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"
            />
    ```

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)