繁体   English   中英

布局编辑器:如何在 framelayout 容器中显示布局?

[英]Layout editor: How to show layout in framelayout container?

我有一个在 XML 中定义为根 ConstraintLayout 的布局,其中包含 4 个用于动态膨胀片段的空 frameLayout。 为了在布局编辑器 (Android Studio) 中获得更好的设计体验,有没有办法在每个框架布局中显示/模仿预期的布局?

这个问题不是关于动态加载容器中的片段(在代码中),我正在寻找一种解决方案,它允许我在布局编辑器的容器/框架布局中加载布局!

根据我的知识和对这个问题的回答, 是不可能的。 但是,在这个问题的答案中,您可以找到一种解决方法。

使用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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM