[英]Layout editor: How to show layout in framelayout container?
I have a layout defined in XML as root ConstraintLayout that contains 4 empty frameLayouts for dynamically inflating fragments.我有一个在 XML 中定义为根 ConstraintLayout 的布局,其中包含 4 个用于动态膨胀片段的空 frameLayout。 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?
为了在布局编辑器 (Android Studio) 中获得更好的设计体验,有没有办法在每个框架布局中显示/模仿预期的布局?
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!这个问题不是关于动态加载容器中的片段(在代码中),我正在寻找一种解决方案,它允许我在布局编辑器的容器/框架布局中加载布局!
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.
但是,在这个问题的答案中,您可以找到一种解决方法。
A workaround using android:visibilty:"gone"
使用
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.